Help!

use script read a .MSG file exported from Outlook

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions RSS
Next:  Send to Mail Recipient (as attachment)  
Author Message
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Tue Jul 26, 2005 2:23 pm    Post subject: use script read a .MSG file exported from Outlook
Archived from groups: microsoft>public>dotnet>languages>jscript, others (more info?)

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.
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Tue Jul 26, 2005 6:45 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You can use Redemption's Import method. See http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message
>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.
>
>
>
>
Back to top
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Tue Jul 26, 2005 6:45 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sue,

Thanks for the response.

I should have mentioned that one of the constraints is no 3rd-party code or
utilities.

Thanks,
Bruce

"Sue Mosher [MVP-Outlook]" wrote in message

You can use Redemption's Import method. See
http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message

>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.
>
>
>
>
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Tue Jul 26, 2005 7:20 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message
> Sue,
>
> Thanks for the response.
>
> I should have mentioned that one of the constraints is no 3rd-party code or
> utilities.
>
> Thanks,
> Bruce
>
> "Sue Mosher [MVP-Outlook]" wrote in message
>
> You can use Redemption's Import method. See
> http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.
>
> "Bruce Hensley" wrote in message
>
>>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.
Back to top
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Tue Jul 26, 2005 7:20 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

"Sue Mosher [MVP-Outlook]" wrote in message

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
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message

> Sue,
>
> Thanks for the response.
>
> I should have mentioned that one of the constraints is no 3rd-party code
or
> utilities.
>
> Thanks,
> Bruce
>
> "Sue Mosher [MVP-Outlook]" wrote in message
>
> You can use Redemption's Import method. See
> http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.
>
> "Bruce Hensley" wrote in message
>
>>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.
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Tue Jul 26, 2005 9:52 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Not without running into security prompts.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message
> 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
>
> "Sue Mosher [MVP-Outlook]" wrote in message
>
> 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
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Bruce Hensley" wrote in message
>
>> Sue,
>>
>> Thanks for the response.
>>
>> I should have mentioned that one of the constraints is no 3rd-party code
> or
>> utilities.
>>
>> Thanks,
>> Bruce
>>
>> "Sue Mosher [MVP-Outlook]" wrote in message
>>
>> You can use Redemption's Import method. See
>> http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.
>>
>> "Bruce Hensley" wrote in message
>>
>>>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.
>
>
Back to top
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Tue Jul 26, 2005 9:52 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sue,

Thanks. I guess it's time to regroup.

Bruce

"Sue Mosher [MVP-Outlook]" wrote in message

Not without running into security prompts.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Bruce Hensley" wrote in message

> 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
>
> "Sue Mosher [MVP-Outlook]" wrote in message
>
> 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
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Bruce Hensley" wrote in message
>
>> Sue,
>>
>> Thanks for the response.
>>
>> I should have mentioned that one of the constraints is no 3rd-party code
> or
>> utilities.
>>
>> Thanks,
>> Bruce
>>
>> "Sue Mosher [MVP-Outlook]" wrote in message
>>
>> You can use Redemption's Import method. See
>> http://www.outlookcode.com/codedetail.aspx?id=716 for sample code.
>>
>> "Bruce Hensley" wrote in message
>>
>>>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.
>
>
Back to top
Dave Methvin
External


Since: Jul 27, 2005
Posts: 2



PostPosted: Wed Jul 27, 2005 2:43 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: microsoft>public>outlook>general, others (more info?)

>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"

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.
Back to top
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Wed Jul 27, 2005 2:43 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

>
> 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"
>
> 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.
>
>
>
Back to top
Dave Methvin
External


Since: Jul 27, 2005
Posts: 2



PostPosted: Wed Jul 27, 2005 4:39 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> 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.
Back to top
Bruce Hensley
External


Since: Nov 08, 2004
Posts: 6



PostPosted: Wed Jul 27, 2005 4:39 pm    Post subject: Re: use script read a .MSG file exported from Outlook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

"Dave Methvin" wrote in message


> 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.
>
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum