Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook. How do I read the contents of attachments that are emails?

Status
Not open for further replies.

uczmeg

MIS
Mar 7, 2001
61
GB
Hi,

We need to process emails that have been returned undeliverable to an Outlook folder.

We store a tag in the original email body with an ID I need.

Some returned emails contain the original message in the email body and stepping through a list of emails and processing the bodies to find the tag is easy enough.

However, in a majority of the returns the original email is an attachment containing the original email (.msg format).

Can anyone one help me work out how to open and scan the contents of that attachment?

I'm working in VB6 and the target Outlook will probably be a fairly recent one (certainly at least from Office 2000)


Thanks
Marc
 

Okay managed to solve it!

Basically you need to save the attachment as a file, and then open it as a Mailitem.

So, assuming there is an attachment and it is a msg file (checks not included in the example)

Dim oApp as Outlook.Application
Dim oMsg As Outlook.MailItem
Dim oMsg2 As Outlook.MailItem

'your code here to find the email messages you want in outlook

'save attachment
oMsg.Attachments.item(1).SaveAsFile App.Path & "temp.msg"

'open it as a new mail item
Set oMsg2 = oApp.CreateItemFromTemplate(App.Path & "temp.msg")

'now do whatever you want with it!
MsgBox oMsg2.Body

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top