use script read a .MSG file exported from Outlook

B

Bruce Hensley

I would like to write a script (JScript or VBScript) that parses fields (to,
from, subject) out of .MSG files that have already been saved to file system
files from Outlook. The method I tried, automating Outlook.Application and
using CreateItemFromTemplate generates the security dialog box and has a
blank From field (since it is creating a new message).

Can this be done by an alternate method (perhaps using CDO, .Net)? If so,
how?

Platform:

Windows 2000 (cdosys.dll)
Outlook 2000 SP3
..NET Framework 1.1

I have no administrative access to the Exchange Server, and its settings are
determined at the Corporate level.
 
S

Sue Mosher [MVP-Outlook]

Then your alternative is to write Extended MAPI code with C++ or Delphi (which is what Redemption does -- it's an ExMAPI wrapper). I have no specific information, however, on what the code for your application might look like, not being an ExMAPI programmer myself.

Note that this task is not possible at all with a scripting language.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bruce Hensley

Thanks.

Bummer. I don't do C or Delphi. Scripting is pretty much it.

Could I open the MSG file and save it as text? If so, I could parse the
text file using FileSystemObject. The only fields I really need are From,
Date, and Subject, which should be available in a text representation.

Bruce

Then your alternative is to write Extended MAPI code with C++ or Delphi
(which is what Redemption does -- it's an ExMAPI wrapper). I have no
specific information, however, on what the code for your application might
look like, not being an ExMAPI programmer myself.

Note that this task is not possible at all with a scripting language.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Not without running into security prompts.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bruce Hensley

Sue,

Thanks. I guess it's time to regroup.

Bruce

Not without running into security prompts.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
D

Dave Methvin

I would like to write a script (JScript or VBScript) that parses fields
(to,
from, subject) out of .MSG files that have already been saved to file
system
files from Outlook. The method I tried, automating Outlook.Application
and
using CreateItemFromTemplate generates the security dialog box and has a
blank From field (since it is creating a new message).

I assume this is using Windows Scripting Host. In another post on the thread
you mentioned no 3rd party utilities.

How about this. For each field you want to retrieve, use the standard
Windows command line FIND utility to search for it in the .msg file This
will have the beneficial side effect of removing the binary data:

FIND "From:" <email.msg >tempfile.txt

That command will generate output something like this:

---------- EMAIL.MSG
From: "Average User" <[email protected]>

Read in the output from the command using FileSystemObject and parse out
what you need using a RegExp or whatever. Do this for each field you want to
find. Make sure you get just the first one (right after the "----" line)
since the email may have other similar lines.

Yes it's a hack but it will probably work 98% of the time.
 
B

Bruce Hensley

Dave,

Good catch. I should have said "I can't add any 3rd party utilities". Yes
WSH is available.

I tried ...

FIND "From:" [my message.msg]
FIND "From" [my message.msg]
FIND "Subject" [my message.msg]
FIND /I "From:" [my message.msg]
FIND /I "From" [my message.msg]
FIND /I "Subject" [my message.msg]
FIND /I "to" [my message.msg]

Only the last one found anything. It found "to" in any of the field
_contents_, e.g. "Christopher", but not in the field names. The field names
are apparently part of the binary component of .MSG files.

Good idea though. Thanks.

Bruce
 
D

Dave Methvin

I tried ...
FIND "From:" [my message.msg]
FIND "From" [my message.msg]
FIND "Subject" [my message.msg]
FIND /I "From:" [my message.msg]
FIND /I "From" [my message.msg]
FIND /I "Subject" [my message.msg]
FIND /I "to" [my message.msg]

Only the last one found anything. It found "to" in any of the field
_contents_, e.g. "Christopher", but not in the field names. The field
names
are apparently part of the binary component of .MSG files.

Hmmm, it seemed to find the To and From fields in an email message that I
saved from Outlook 2003. All my mail comes through POP3 though, are your
messages from an Exchange server? That could make a difference. Also, be
sure to save the .msg in non-Unicode format.
 
B

Bruce Hensley

These messages are already saved on the fileserver, and were saved by
dragging and dropping from Outlook 2000 SP3, not File > Save As.

Yes, they are from Exchange.
 

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