Searching for information in Message Header

  • Thread starter Rafal Harrison-Staska
  • Start date
R

Rafal Harrison-Staska

Hi guys,

I was looking for a way I could search the message header for a string :
"Message-ID: *@DEUN" but unfortunately I cannot use rules "*" because it
doesn't recognize "*" as an expression but treats it as a character. Im
talking here about a rule "with specific words in the message header"
Is there any way I can use search expressions like * , ?, 1-7 ?
Or maybe there is a way to search just for string in Message-ID field ?
That would be better cause I would be able to build a rule that would query
the message header, but only one field in message header : Message-ID.
If I search the whole message header the strings Im looking for appear
sometimes in different fields and I can get wrong results.
 
S

Sue Mosher [MVP-Outlook]

What you're describing is a technique called "regular expressions" that allows you to search for text using patterns. See http://www.outlookcode.com/d/vbscript.htm#regex for some basic references on how to code it.

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

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

Rafal Harrison-Staska

Hi Sue,

I was just wondering how I can use them when building rules from within
Outlook rules wizard ? Or do I have to write a macro ?

What you're describing is a technique called "regular expressions" that
allows you to search for text using patterns. See
http://www.outlookcode.com/d/vbscript.htm#regex for some basic references on
how to code it.

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

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

Sue Mosher [MVP-Outlook]

Rules Wizard doesn't support regular expressions directly. You could, however, write code for a "run a script" rule action, which 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.Body

Set msg = 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

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

Rafal Harrison-Staska

Hi Sue,

Thanks :)

Rafal


Rules Wizard doesn't support regular expressions directly. You could,
however, write code for a "run a script" rule action, which 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.Body

Set msg = 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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top