I am using this code in outlook, and it's crashing. I took over process for someone else, not outlook VBA expert, any ideas ?
The error is here:
Set myinboxfolder = myInbox.Folders(3)
Run-time error '-2147352567 (80020009)';
Array index out of bounds
Any idea ?
Sub ExportAll()
' copies every messages from the IN Box and
Dim Message As MailItem
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myinboxfolder = myInbox.Folders(3)
For Each Message In myinboxfolder.Items
Message.Categories = "CCG Job"
Message.Save
Next Message
End Sub
The error is here:
Set myinboxfolder = myInbox.Folders(3)
Run-time error '-2147352567 (80020009)';
Array index out of bounds
Any idea ?
Sub ExportAll()
' copies every messages from the IN Box and
Dim Message As MailItem
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myinboxfolder = myInbox.Folders(3)
For Each Message In myinboxfolder.Items
Message.Categories = "CCG Job"
Message.Save
Next Message
End Sub