PC Review


Reply
Thread Tools Rate Thread

How do I script to change the subject line of incoming mail?

 
 
=?Utf-8?B?R2xlbm4gSGFybGVzcw==?=
Guest
Posts: n/a
 
      11th Nov 2005
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
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      11th Nov 2005
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

 
Reply With Quote
 
=?Utf-8?B?R2xlbm4gSGFybGVzcw==?=
Guest
Posts: n/a
 
      11th Nov 2005
Thanks Sue. I'll give it a shot
 
Reply With Quote
 
=?Utf-8?B?RC1NYW4=?=
Guest
Posts: n/a
 
      29th Jan 2007
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

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      29th Jan 2007
What in particular doesn't work? Did you check the VBA basics at http://www.outlookcode.com/d/vbabasics.htm?

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

"D-Man" <D-(E-Mail Removed)> wrote in message news:E32BB03B-C654-44D3-A810-(E-Mail Removed)...
> 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

>>

 
Reply With Quote
 
=?Utf-8?B?RC1NYW4=?=
Guest
Posts: n/a
 
      29th Jan 2007
I did go through that document. Could the problem be that if the faxes are
not going to the default inbox but rather than another user account mailbox?
Do I need to make changes in the script to reflect that?

Thanks in advance.

"Sue Mosher [MVP-Outlook]" wrote:

> What in particular doesn't work? Did you check the VBA basics at http://www.outlookcode.com/d/vbabasics.htm?
>
> --
> 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
>
> "D-Man" <D-(E-Mail Removed)> wrote in message news:E32BB03B-C654-44D3-A810-(E-Mail Removed)...
> > 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
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      29th Jan 2007
The code you cited works with an Outlook rule, which means it affects only messages coming into your own mailbox. To handle items in another mailbox with Outlook code, you would have to leave a machine running 24/7 and use a different coding approach -- the MAPIFolder.Items.ItemAdd event.

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

"D-Man" <(E-Mail Removed)> wrote in message news:2DEAF489-A128-42EF-9550-(E-Mail Removed)...
>I did go through that document. Could the problem be that if the faxes are
> not going to the default inbox but rather than another user account mailbox?
> Do I need to make changes in the script to reflect that?
>
> Thanks in advance.
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> What in particular doesn't work? Did you check the VBA basics at http://www.outlookcode.com/d/vbabasics.htm?
>>
>> "D-Man" <D-(E-Mail Removed)> wrote in message news:E32BB03B-C654-44D3-A810-(E-Mail Removed)...
>> > 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.


>> >>
>> >>
>> >> "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
>> >>

>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 change incoming subject line font seattlej Microsoft Outlook Discussion 3 28th Oct 2009 02:14 PM
Script to forward e-mail to address in Subject line mleviton@juno.com Microsoft Outlook VBA Programming 2 7th Sep 2006 02:45 PM
Updating subject line on incoming e-mail =?Utf-8?B?SmF3d3dz?= Microsoft Outlook Installation 1 3rd Dec 2004 10:45 PM
Adding code to ThisOutlookSession Made Incoming Subject Line to Have Now() as Subject Mark Microsoft Outlook VBA Programming 1 9th Feb 2004 06:45 PM
Editing the Subject Line of Incoming Mail Jennie Sebrasky Microsoft Outlook 0 10th Jul 2003 03:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:25 PM.