p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual Basic 2010 General Discussion (http://p2p.wrox.com/forumdisplay.php?f=580)
-   -   Access the body of Outlook E-mail through VBA (http://p2p.wrox.com/showthread.php?t=99953)

CarlFelix24 July 25th, 2018 10:00 PM

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?


All times are GMT -4. The time now is 10:23 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.