Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read email object in VBA from saved .msg file

Posted on 2010-11-28
3
Medium Priority
?
2,868 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 2000 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 85
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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