Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Location: London
Posts: 78
Default VBA Integration with Outlook: Mail Item objects from .msg files

Hi All.

It's a long time since I've posted on here. I hope someone can help me with the following:

We regularly save batches of e-Mails received via Outlook onto our network drive as .msg files. This saves having one big .pst file that only one person can open and navigate at any one time. Also we have this (rather arcane, I know) requirement to save them in what the big chiefs call a "day file". Yeah, I know. Went out with the ark. Or should have done.

What I want to do though is write a routine which automatically looks for an older message to link a newer message to if it contains a reply to that older message. For that bit, I already have the routine. Also, I want to check the attachments within it and use a combination of the date sent of the e-Mail and the Date Last Modified of the attachments to work out where in the document workflow that particular e-Mail in/out sits.

Again, I have all the algorithm to do that worked out.

HOWEVER - what I need to be able to do is access the previously saved .msg files as MailItem objects. So that I can read the sent date/time, recipient list properties and so on.

This is where I'm stuck. The only way so far I have been able to convert .msg files into MailItem objects is to do the following:

tFilename = "N:\My e-Mail.msg"
Set xItem = Application.CreateItemFromTemplate(tFilename)

However what this returns is a MailItem object for an un-sent COPY of the message. Therefore, trying to read the .SentOn property returns an error because the mail item isn't sent. Opening the MailItem object for display shows the message as an editable copy as you would expect.

This of course is no good to me as what I want to be able to do is operate on these files, give the user the option to display them if necessary, with all sending information in the headers intact both as visual proof of successful transmission and so I can work on it in my macro.

BTW I also tried:

Call Application.CopyFile ("N:\my e-Mail.msg","Inbox")

...which 'sort of' works - i.e. it imports the .msg file into the Inbox folder - but again, it is reported only as a generic file "Item" - NOT a "MailItem". So again, trying to access any mail-send related properties fails - i.e. you can't access any .To or .SentOn properties, etc. In essence, the Item is viewed by Outlook merely as a 'document' of type .msg.

So, is there any OTHER way of importing an .msg file back into a MailItem object or importing it into a MAPI folder so that I can read it from the MailItem collection in that folder? That would be the final piece of my puzzle.

Thanks tremendously to anyone who can come up with the answer to this!

Mark
London

Last edited by BizMark : July 28th 08 at 12:58 PM
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an Outlook Task Item John Google Excel Discussion (Misc queries) 3 November 6th 07 07:58 PM
E-Mail attachment to same e-mail address in Outlook Vick Excel Discussion (Misc queries) 4 May 17th 07 07:53 PM
.xls files become scrap objects - .shs files Sali Excel Discussion (Misc queries) 1 January 31st 06 02:59 PM
IF function for scheduling tool with outlook integration systematic Excel Worksheet Functions 3 December 17th 05 01:00 AM
Outlook Integration Bdavis Excel Discussion (Misc queries) 0 April 14th 05 05:02 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"