View Single Post
  #1 (permalink)  
Old July 25th, 2018, 10:00 PM
CarlFelix24 CarlFelix24 is offline
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2018
Location: Altamont, NY
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access the body of Outlook E-mail through VBA

Hi everyone,

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?

Reply With Quote