Solved

Read email object in VBA from saved .msg file

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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