vba - Run Excel Macro from Outlook, Triggered Based on Email Subject -


i'm trying set automated process when receive email in outlook containing "subject" automatically fires off macro open attached .xls file in excel , run macro have set in excel. how can accomplished?

can provide more information if necessary - thanks!

there 2 possible ways implementing task.

the first 1 create outlook rule assign vba macro running when rule triggers. vba macro sub should following one:

public sub test(mail mailitem)    ' here end sub 

the second way handle newmailex event of application class. in case there no need create rule in outlook. code triggered event. here msdn states:

this event fires once every received item processed microsoft outlook. item can 1 of several different item types, example, mailitem, meetingitem, or sharingitem. entryidscollection string contains entry id corresponds item.

the newmailex event fires when new message arrives in inbox , before client rule processing occurs. can use entry id returned in entryidcollection array call namespace.getitemfromid method , process item. use method caution minimize impact on outlook performance. however, depending on setup on client computer, after new message arrives in inbox, processes spam filtering , client rules move new message inbox folder can occur asynchronously. should not assume after these events fire, one-item increase in number of items in inbox.

in code need automate excel. run method of application class can used run vba macro programmatically.

finally, may find getting started vba in outlook 2010 article helpful.


Comments