I am looking for a way to fire a VBA macro when a message is moved
from Inbox to a specific subfolder of inbox. Is there an event
associated with this action?
The scenario is this. I'm a systems admin, and I receive a huge
number of NDRs every day, and I need a way to sort them sanely. The
rules wizard doesn't allow me to fire a macro based on any of the
standard tests, but I CAN move the message to a subfolder based on
these tests.
What I want to have happen is that when an NDR gets moved to a
subfolder called NDRs, a macro associated with the NDRs folder gets
run on the new member.
Is this possible? If not, what workarounds exist?
Thank you for your time and trouble,
Barney
Paste this code into your ThisOutlookSession module:
Option Explicit
Dim WithEvents objNDRFolderItems As Outlook.Items
Private Sub Application_Startup()
On Error Resume Next
Dim objInbox As Outlook.MAPIFolder, objNS As Outlook.namespace
Dim objFolder As Outlook.MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("NDRs")
Set objNDRFolderItems = objFolder.Items
End Sub
Private Sub Application_Quit()
Set objNDRFolderItems = Nothing
End Sub
Private Sub objNDRFolderItems_ItemAdd(ByVal Item As Object)
'note that ItemAdd may not fire if large number of items are added to it at the same time
'run a macro
'RunMyProcedure
End Sub
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
It works like a charm! THANK YOU!!! Definitely, you ARE an MVP.
Your prediction RE large numbers of messages is dead on, too.
Barney
"Eric Legault [MVP - Outlook]" <elega...@REMOVEZZZmvps.org> wrote in message news:<15E211FD-8763-4ABA...@microsoft.com>...