Solved

Read email object in VBA from saved .msg file

Posted on 2010-11-28
3
2,230 Views
Last Modified: 2012-06-27
I have a saved email on my hard drive (let's call it 'c:\mailmsg.msg').  Using Access VBA, how can I read the message to parse the properties (Sender, Subject, etc.)?

Thanks in advance.
0
Comment
Question by:DaneBigham
3 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34227925
No.

.msg files are binary files, and as such, really do not contain any text you can parse.

Can I ask why this file is "my hard drive" and not in Outlook?
If the email was still in outlook, you could link to the folder it was in and access all of the info you are requesting in MS Access.

In Access 2003 and older click;
File-->Get External data-->link Tables
The select Outlook...

In Access 2007 and newer select:
External data-->Import data-->More-->Outlook Folder-->Link to the datasource...

JeffCoachman
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34229179
You could so it in VBA  - if you had to go that route - by automating Outlook.  I used the code below from Excel

To escape the Outllok security message you would either use Redemption (which would need code tweaking) or clickyes, http://www.contextmagic.com/express-clickyes/

Cheers

Dave
Sub DirtyMsg()
Dim ObjOutlook
Dim MyItem 
Set ObjOutlook = CreateObject("outlook.application")
Set MyItem = ObjOutlook.CreateItemFromTemplate("C:\temp\aaa.msg")
Debug.Print MyItem.Sender & Chr(10) & MyItem.Subject
ObjOutlook.Quit
Set ObjOutlook = Nothing
End Sub

Open in new window

0
 
LVL 84
ID: 34229573
Note you can also use vbMAPI from www.everythingaccess.com to get around the Outlook security prompts. It's cheaper than Redemption, and requires no external deployment. I have no affiliation with the developer except as a satisfied customer.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Find out what you should include to make the best professional email signature for your organization.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now