I copied the following code from vbaexpress.com over a year ago. (Modified it slightly to fit my needs.) It's worked perfectly for over a year. It now fails on the line:
Set mlItm = itm
Possible reason(s)?
Thank you.
===========================================================
'Created by : Charlize
'Revised by : Oorang
' Rewrote a call and jump loop to a Do Until Loop
' Instead of the original if's for the
' attachments, he came up with an array
' of file extensions (pretty slick)
'Rerevised by : Charlize
'Submitted by : Charlize / slight modifications by DRouse
'Date : 2007-10-11 (11 oct 2007)
'Purpose : strip attachments from
' emails to reduce mailbox size
' Save them to a specified folder and
' put a notification in the mail where
' the file was saved to.
Public Sub TestAttachmentRule_Original()
Const lngNoAttchmt_c As Long = 0
Dim Ns As Outlook.NameSpace
Dim mFldr As Outlook.MAPIFolder
Dim itm As Object
Dim mlItm As Outlook.MailItem
Set Ns = Outlook.Application.Session
Set mFldr = Ns.GetDefaultFolder(olFolderInbox)
'List all the file types that you want to save
For Each itm In mFldr.Items
If itm.Class = olMail Then
Set mlItm = itm
If mlItm.Attachments.Count <> lngNoAttchmt_c Then
SaveAttachmentRule mlItm, ".doc", ".xls", ".pdf", ".ppt", ".tif", ".zip"
End If
End If
Next
MsgBox "Files are extracted from" & vbCrLf & _
"the emails in inbox folder.", vbInformation
End Sub
Set mlItm = itm
Possible reason(s)?
Thank you.
===========================================================
'Created by : Charlize
'Revised by : Oorang
' Rewrote a call and jump loop to a Do Until Loop
' Instead of the original if's for the
' attachments, he came up with an array
' of file extensions (pretty slick)
'Rerevised by : Charlize
'Submitted by : Charlize / slight modifications by DRouse
'Date : 2007-10-11 (11 oct 2007)
'Purpose : strip attachments from
' emails to reduce mailbox size
' Save them to a specified folder and
' put a notification in the mail where
' the file was saved to.
Public Sub TestAttachmentRule_Original()
Const lngNoAttchmt_c As Long = 0
Dim Ns As Outlook.NameSpace
Dim mFldr As Outlook.MAPIFolder
Dim itm As Object
Dim mlItm As Outlook.MailItem
Set Ns = Outlook.Application.Session
Set mFldr = Ns.GetDefaultFolder(olFolderInbox)
'List all the file types that you want to save
For Each itm In mFldr.Items
If itm.Class = olMail Then
Set mlItm = itm
If mlItm.Attachments.Count <> lngNoAttchmt_c Then
SaveAttachmentRule mlItm, ".doc", ".xls", ".pdf", ".ppt", ".tif", ".zip"
End If
End If
Next
MsgBox "Files are extracted from" & vbCrLf & _
"the emails in inbox folder.", vbInformation
End Sub