rules to run macro

  • Thread starter Thread starter DSPettit
  • Start date Start date
D

DSPettit

Hello all,

Is there a way to cause a rule to run a macro? I have a macro written that
runs fine if invoked manually, but I don't seem to be able to find a way to
cause a rule to run a macro.

Thanks,
Doug
 
A "run a script" rule action actually can run a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
MsgBox msg.SUbject

Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue,

Thanks for the help. I see what you are saying. Unfortunately, I am running
Outlook 2000 SP-3, and "run a script" is not available. I am guessing that
my best option is to upgrade to something more current.

Any other thoughts or ideas?

Thanks,
Doug


A "run a script" rule action actually can run a VBA procedure with a
MailItem or MeetingItem as its parameter. That item is processed by the
code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
MsgBox msg.SUbject

Set msg = Nothing
Set olNS = Nothing
End Sub

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Either that or use the ItemsAdd different approach; see http://www.outlookcode.com/d/code/zaphtml.htm

Now you know that you really need to include your Outlook version whenever you post here.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top