Solved

Read email object in VBA from saved .msg file

Posted on 2010-11-28
3
2,147 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

760 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

21 Experts available now in Live!

Get 1:1 Help Now