J
Jake Cole
When using this code to loop through ALL the items in an Outlook
Inbox, instead of moving every item, the code moves exactly half of
the mail items each time it is run
Here is the current code. I would like the code to move all inbox
items to the "completed" folder, -instead of just half, can anyone
tell me what the problem is with this code?! (This code is run from
within an access database.)
Dim mapiNameSpace As Outlook.NameSpace
Dim fldInbox As MAPIFolder
Dim newMail As MailItem
Dim fldMoveTo As MAPIFolder
Dim myTime
Dim olO As Outlook.Application
Dim sFolder As Outlook.Recipient
Set olO = New Outlook.Application
Set mapiNameSpace = olO.GetNamespace("MAPI")
Set sFolder = mapiNameSpace.CreateRecipient("Conference 2004")
Set fldInbox = mapiNameSpace.GetSharedDefaultFolder(sFolder,
olFolderInbox)
Set fldMoveTo = fldInbox.Folders("Completed")
cm = 0
MsgBox fldInbox.Items.Count
For Each newMail In fldInbox.Items
cm = cm + 1
newMail.Move fldMoveTo
Next
MsgBox cm & " Records Moved!"
End Sub
Thanks,
Jake
Inbox, instead of moving every item, the code moves exactly half of
the mail items each time it is run
Here is the current code. I would like the code to move all inbox
items to the "completed" folder, -instead of just half, can anyone
tell me what the problem is with this code?! (This code is run from
within an access database.)
Dim mapiNameSpace As Outlook.NameSpace
Dim fldInbox As MAPIFolder
Dim newMail As MailItem
Dim fldMoveTo As MAPIFolder
Dim myTime
Dim olO As Outlook.Application
Dim sFolder As Outlook.Recipient
Set olO = New Outlook.Application
Set mapiNameSpace = olO.GetNamespace("MAPI")
Set sFolder = mapiNameSpace.CreateRecipient("Conference 2004")
Set fldInbox = mapiNameSpace.GetSharedDefaultFolder(sFolder,
olFolderInbox)
Set fldMoveTo = fldInbox.Folders("Completed")
cm = 0
MsgBox fldInbox.Items.Count
For Each newMail In fldInbox.Items
cm = cm + 1
newMail.Move fldMoveTo
Next
MsgBox cm & " Records Moved!"
End Sub
Thanks,
Jake