Solved

Read email object in VBA from saved .msg file

Posted on 2010-11-28
3
2,514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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 …

710 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