Read body of MailItem ?

T

Trey Shaffer

I need to create a "Script" for a "run a script" rule action.

I am new to the Outlook object model, but familiar with VBScript.

I could use a pointer to some documentation, as I haven't found anything
clear and straightforward.

My immediate issue is accessing the body text of a message to evaluate the
contents.

I think the shortest question might be... What is the method/syntax to get
the body text, and what type of variable is it, string, collection, etc.?

I can work with it once I get a handle to it...
 
S

Sue Mosher [MVP-Outlook]

It's a string, Body.

Use this syntax for your "run a script" rule to avoid security prompts in Outlook 2003:

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.
MsgBox olMail.Body

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

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