VBA Integration with Outlook: Mail Item objects from .msg files

B

BizMark

Hi All.

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

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

What I want to do though is write a routine which automatically look
for an older message to link a newer message to if it contains a repl
to that older message. For that bit, I already have the routine.
Also, I want to check the attachments within it and use a combinatio
of the date sent of the e-Mail and the Date Last Modified of th
attachments to work out where in the document workflow that particula
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 save
.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 t
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 o
the message. Therefore, trying to read the .SentOn property returns a
error because the mail item isn't sent. Opening the MailItem object fo
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 i
operate on these files, give the user the option to display them i
necessary, with all sending information in the headers intact both a
visual proof of successful transmission and so I can work on it in m
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 Inbo
folder - but again, it is reported only as a generic file "Item" - NOT
"MailItem". So again, trying to access any mail-send related propertie
fails - i.e. you can't access any .To or .SentOn properties, etc. I
essence, the Item is viewed by Outlook merely as a 'document' of typ
.msg.

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

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

Mark
Londo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top