franksirvent
Programmer
Hi there
I have the following code (part of) which goes through a folder in Outlook and saves the attachments to C:\attachments
It all works well, however if there are 3 emails in the folder, it only reads the first 2.
So it seems to leave 1 email till the next time code is run...
Is there a way of processing all emails without leaving any behind ????
thanks in advance
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set oFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set oExtractFolder = oFolder.Folders("EXTRACTS")
For Each Item In oExtractFolder.Items
strControl = strControl + 1
If InStr(Item.Subject, "ESVIT02") Then
Item.Attachments.Item(1).SaveAsFile "C:\ATTACH\XXX.ZIP"
Item.Delete
Else
End If
Next Item
I have the following code (part of) which goes through a folder in Outlook and saves the attachments to C:\attachments
It all works well, however if there are 3 emails in the folder, it only reads the first 2.
So it seems to leave 1 email till the next time code is run...
Is there a way of processing all emails without leaving any behind ????
thanks in advance
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set oFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set oExtractFolder = oFolder.Folders("EXTRACTS")
For Each Item In oExtractFolder.Items
strControl = strControl + 1
If InStr(Item.Subject, "ESVIT02") Then
Item.Attachments.Item(1).SaveAsFile "C:\ATTACH\XXX.ZIP"
Item.Delete
Else
End If
Next Item