Reading outlook .msg files

  • Thread starter Thread starter Graham F French
  • Start date Start date
G

Graham F French

Hello,

I can read text files into my application, but I cannot read in msg files as
they seem to be in a proprietry format.

Is there anyway of converting it on the fly or is there an interpretation
method?

Thanks

Graham

Graham F French mcse
 
their in binary format not text format, to read binary format you need to
know the data structure of the file.
 
Jay,

Sorry, I do need to know how to read this file format directly into my
application.

I know that it can be done in VB6.

Cheers

Graham
 
CJ,

You are dead right, I have never worked with binary.

I still consider myself as a newbie, text files are no problem, binary.....
not a chance!!

The site that you showed me has not got the msg format.

Any further help would be appreciated.

Thanks

Graham
 
Hmm, sorry, didn't look through it enough... Sorry about that.. still
searching for a source of it.. but personally, I would use the Outlook
interop.
-CJ
 
The problem is the client. Outlook will not be installed.

The msg files are saved to a shared server drive and my application needs to
read in the msg files.

Cheers

Graham
 
Not to be a noot, but I think you're on the wrong track. .msg files ARE
NOT MS Outlook files, but e-mail messages that are used by a thousand or so
clients. There is both an ISO and RFC spec on this. Check out .msg email
file layouts, that may lead to some clues, and remember, MS doesn't have the
market on everything, even though they'd like to :)

HTH
Sueffel
 
And actually, I posted before I thought bout it more, email messages are
required to be plain-text unless they are encrypted. If they are encrypted
by Outlook for whatever reason, you're pretty hosed. Ofcourse, not 100%
sure what Outlook may be doing to this file, but it sure is really fubared,
and needs to be avoided LOL
It looks to be a non-stander, IE fubared, db type of format, let me see
what I can dig up for ya...

Sueffel
 
Hi Graham,

I got this links from Jay B. we work in a team like that.

You can read them and Jay B has a lot of more answers.

http://www.microeye.com/resources/res_outlookvsnet.htm

http://msdn.microsoft.com/library/d...html/frlrfsystemwebmailsmtpmailclasstopic.asp

http://msdn.microsoft.com/library/d...y/en-us/exchanchor/htms/msexchsvr_cdo_top.asp


The four CDOs are (in chronological order):

- CDO.DLL : CDO version 1.2.1
- CDONTS.DLL : CDO version 1.2.1 for Windows NT Server (not the same as CDO
version 1.2.1!)
- CDOSYS.DLL : CDO for Windows 2000
- CDOEX.DLL : CDO for Exchange 2000 Server

And the last is probably what you need.

Look at the outlook and exchange part in it, but I think in this case take
first the Exchange part, because you have to read the message storage from
that server for what you want I thouhgt.

Cor
 
Binary files are a defined data structure. you have to know how to read in
the structures in teh correct data type to be able to convery from binary to
something you can use, I'd suggest reading up on binary format files first
then search for a binary file format document on outlook second..
 
Sueffel said:
And actually, I posted before I thought bout it more, email messages are
required to be plain-text unless they are encrypted. If they are encrypted
by Outlook for whatever reason, you're pretty hosed. Ofcourse, not 100%
sure what Outlook may be doing to this file, but it sure is really fubared,
and needs to be avoided LOL
It looks to be a non-stander, IE fubared, db type of format, let me see
what I can dig up for ya...

Sueffel

Well damn,MS strikes again with propritary format! I've seen .msg files
many time on linux email servers, but it seems that this is something MS has
tried to say, "Hey, this is ours and there's nothing you can do about it".
That sucks, I will look somemore thoguh unless those links jay giave are the
answer.

Sueffel
 
Hi,

I have yet to find some info on this, anything you can get would be
appreciated!

Thanks

Graham
 
Graham,
Sorry, I do need to know how to read this file format directly into my
application.
I'm Sorry, which part of "not documented" do you not understand? :-|
I know that it can be done in VB6.

If you know how to do it in VB6, then you *should* know how to do it in
VB.NET.

Can you post the VB6 code you are using? The code should largely translate
into VB.NET, nothing else, create a simple VB6 project that uses the code,
then use the Upgrade Wizard in VB.NET to open the project.

Hope this helps
Jay
 
Hi Jay,

I don't know vb6 at all. It sounds strange, but I stared off with vbscript!
Then I moved to asp.net.

I could post the vb6 code that reads the file in, as it doesn't make much
sense to me.

Regards

Graham
 
Outlook uses the OLE structured storage file format to write the .msg files.
To read these files you have to use the OLE api. There's a set of VB.NET
classes that wraps this API in my site:

Once you download the classes you can use this code to read the message
body:

' Open the message file
Dim msg As New Storage("test.msg")

' Get the message body stream
Dim stream As OleStorage.Stream = msg.OpenStream("__substg1.0_80050102")
Dim reader As New IO.StreamReader(stream)

' Show the message body
MsgBox(reader.ReadToEnd)

' Close the stream
reader.Close()
stream.Close()

' Close the message file
msg.Close()

The following are the streams I know:

__substg1.0_0037001E -> subject
__substg1.0_0050001E -> sender's email
__substg1.0_0650001E -> sender's email
__substg1.0_0760001E -> recipient's email
__substg1.0_07D0001E -> headers
__substg1.0_0C1F001E -> sender's email
__substg1.0_1000001E -> message body
__substg1.0_1035001E -> message id
__substg1.0_1046001E -> sender's email
__substg1.0_80050102 -> message body
 
Back
Top