Good Morning Sue,
I am new to scripting in VBA but I have done some vbs scripting. We receive
about 25,000 faxes and they are sent to an Outlook Mailbox. The subject of
the e-mails contain the senders fax number. We would like to have a rule
change the fax number to the customers name when the e-mail arrives. I tried
your code below with the changes below but I am unable to get it to work.
Would you be so kind as to help me through this?
Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' do stuff with olMail, e.g.
If olMail.Subject = "555-1212" Then
olMail.Subject = "New Customer"
olMail.Save
End If
Set olMail = Nothing
Set olNS = Nothing
End Sub
Thanks In advance
"Sue Mosher [MVP-Outlook]" wrote:
> One way is to use a "run a script" rule, a Rules Wizard action that invokes a VBA procedure with a MailItem or MeetingItem as its parameter, then uses that item in the code:
>
> Sub RunAScriptRuleRoutine(MyMail As MailItem)
> Dim strID As String
> Dim olNS As Outlook.NameSpace
> Dim olMail As Outlook.MailItem
>
> strID = MyMail.EntryID
> Set olNS = Application.GetNamespace("MAPI")
> Set olMail = olNS.GetItemFromID(strID)
> ' do stuff with olMail, e.g.
> olMail.SUbject = "whatever you want the subject to be"
> olMaIl.Save
>
> Set olMail = Nothing
> Set olNS = Nothing
> End Sub
>
> See http://www.outlookcode.com/d/code/zaphtml.htm#ol2002 for another example.
>
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Glenn Harless" <(E-Mail Removed)> wrote in message news:861A23A5-2DB6-4E28-B38C-(E-Mail Removed)...
> >I wish to create a script to alter the subject line of incoming mail to
> > remove certain character strings.
> >
> > Google has not been much help...any suggestions or guidence is appreciatied
>