0
votes

.Body of Mailitem is not returning anything

I am using the entryID to get access to the inbound email and set the object using Application.Session.GetItemFromID

strID = olitem.EntryID
Set olitem = Application.Session.GetItemFromID(strID)

Once I set olitem
Set olitem = Application.Session.GetItemFromID(strID) it shows the email has been accessed, but when sText = olitem.Body is run stext ends up empty.

Here is the entire code that is fired from an Outlook Rule. This shows watch window with .body empty

Sub ParseEPDMRequest(olitem As Outlook.MailItem)


Dim arr() As String
Dim ECONum As String
Dim ReqID As String

Dim sText As String
Dim strID As String

strID = olitem.EntryID
Set olitem = Application.Session.GetItemFromID(strID)

sText = olitem.Body
arr = Split(olitem.Body, ":")
arr = Split(arr(15), " ")
ECONum = GetECONum(arr(8))
sText = olitem.Subject
ReqID = GetReqId(sText)

Call TEAMtoEPDMPush(ECONum & ".xml", ReqID)

End Sub
1

1 Answers

0
votes

Under certain circumstances the message can have no plain text body. You have to check the format of the body (see BodyFormat property):

strID = olitem.EntryID
Set olitem = Application.Session.GetItemFromID(strID)
If olitem.BodyFormat=OlBodyFormat.olFormatPlain Then
   sText = olitem.Body
   ...
ElseIf  olitem.BodyFormat=OlBodyFormat.olFormatHTML Then 
   ...