Create rule to run script

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a vb script that when run takes the attachment on an e-mail and
places it in a folder. Is there any way to setup a rule in outlook that
when an e-mail is received from a certain person or address, to
automatically run this script to place the attachment in the specified
folder?

Thanks in advance
 
A "run a script" rule action actually uses not an external script but 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.Attachments.Count

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
 
Back
Top