I have found myself accidentally moving email items to an Archive folder instead of the standard folder in MS Outlook. For example, for an email address of Example@Email.Com, I open the Archive to locate an old email in folder "KeepThis" but then I forget to collapse the Archive folder and so I inadvertently move some other email message later on into the Archive/KeepThis folder when I really wanted to move it to the Example@Email.Com/KeepThis folder.
Is there a way to use VBA code to alert the user when an email item is manually moved into an Archive folder?
I tried unsuccessfully to modify the code by @thims at create-outlook-rule-which-runs-after-move-mail-to-specific-folder to show a msgbox, but could not figure out how to get it to trigger when I moved a mail item to any folder in either my main email folder nor in the Archive.
Here is what I've tried:
(1) I added the following code to ThisOutlookSession (obviously with my actual email address):
Public WithEvents FolderItems As Outlook.Items
Private Sub Application_Startup()
Set FolderItems = Session.Folders("Example@Email.Com").Folders("Misc").Items
End Sub
Private Sub FolderItems_ItemAdd(ByVal Item As Object)
MsgBox "ItemAdd event was triggered in folder Misc"
End Sub
That works if I move an email item into the "Misc" folder in my non-archived email account. Yay.
But, I cannot figure out how to set the FolderItems object to trigger when an email is moved to any folder.
(2) I can reference the general Archive folder by using:
Set FolderItems = Session.Folders("Archives").Folders("Misc").Items
But, that only triggers if I move something to the specific "Misc" folder in Archives and I want to trigger the event when an email is moved to any Archive folder, not just the "Misc" folder.
I've tried
Set FolderItems = Session.Folders("Archives").Items
but that does not work--there's no error, it just does not trigger when I move an email into any folder, nor does it trigger when a new folder is added/created in Archives; so, I'm not sure what will trigger with that code.
Thanks for any pointers to get things further along!