Hi Guys,
I've got some outlook code which manipulates emails, saves them elsewhere, and now i am required to simply tick a box thats says 'delete original' which basically, will delete the original from the inbox.
My method behind this was to flag the email as 'olFlagMarked' and then a simple statement that runs through the inbox, deleting flagged emails. I tried this because the approach of simply deleting the email, kept throwing up an 'Outlook cannot delete this item' error, and i'm getting that same error now. I just wanna know why.
Thats basically the code i've attempted to use, and the same error crops up everytime. Whether i run it from a function, directly after the other code, or in a seperate macro altogether... Hmmm
Thanks
I've got some outlook code which manipulates emails, saves them elsewhere, and now i am required to simply tick a box thats says 'delete original' which basically, will delete the original from the inbox.
My method behind this was to flag the email as 'olFlagMarked' and then a simple statement that runs through the inbox, deleting flagged emails. I tried this because the approach of simply deleting the email, kept throwing up an 'Outlook cannot delete this item' error, and i'm getting that same error now. I just wanna know why.
Code:
Dim ns As NameSpace
Dim inbox As MAPIFolder
Dim mail As mailItem
Set ns = Application.GetNamespace("MAPI")
Set inbox = ns.GetDefaultFolder(olFolderInbox)
For Each mail In inbox
If mail.FlagStatus = olFlagMarked Then
mail.Delete
End If
Next
Thats basically the code i've attempted to use, and the same error crops up everytime. Whether i run it from a function, directly after the other code, or in a seperate macro altogether... Hmmm
Thanks