Access the body of Outlook E-mail through VBA
I am using MS office 2010 (MS Outlook) and Windows 7 Ultimate. I am trying to obtain information from certain E-mails when they are received to update an Access database. I used the following code to obtain the subject, E-mail address and received time. However the body fields were empty.
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim strSQL As String
Dim MyMail As MailItem
Set MyMail = Application.Session.GetItemFromID(EntryIDCollectio n)
Dim MySubject As String
Dim MySender As String
Dim MyTime As Date
Dim MyBody As String
MySubject = MyMail.Subject
MySender = MyMail.SenderEmailAddress
MyTime = MyMail.ReceivedTime
MyBody = MyMail.Body
I've also tried obtaining info from the Outlook.Mailitem object but it does not point to the current E-mail.
Is there any VBA code that shows how to retrieve the body from an incoming E-mail that was just received?