Read header, body and fileds from Outlook (.MSG file) using VB

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Is there any way to read the Outlook email header (Internet Header), body
and fields from a specific .msg-file (using path to file) through Visual
Basic (VB 6 or VB.Net)


Thks,

Robert

robert_rdk@[email protected]
 
Using the Outlook Object Model, no. Using Collaboration Data Objects, yes.
(Hint: Attach the *.msg file to a temporary new message. There is a
property exposed by the attachment object called source.)
 
If you are looking for a way to export the entire message out to a text file
(e.g. get the rfc2822 stream), you should consider using Redemption
(http://www.dimastr.com/redemption/). Perhaps he will see this question and
post a link to an example on how to use the redemption library to perform
the export on a message.

Robert said:
It is not my intension to distribute the library without these products. (
don't worry ;-)) )

The only reason is that Outlook can't show the complete message source (like
Outlook express).

I think that the only remaining possibility is, creating a macro showing
(and saving as txt-file) the complete message source.



I appreciate it if there is an example and someone will share it.



Now I have this (extracting the header):



Sub ExtractMsgSource()

Dim oSession As MAPI.Session

Dim oFolder As Folder

Dim oMsgColl As Messages

Dim oMessage As Message



' Logon to the MAPI session

Set oSession = New MAPI.Session

oSession.Logon



' Get the Inbox folder and its message collection.

Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderInbox)

Set oMsgColl = oFolder.Messages



For Each oMessage In oMsgColl

MsgBox oMessage.Fields(&H7D001E) 'Display the header

Next



' Logoff and cleanup

oSession.Logoff

Set oSession = Nothing

Set oMessage = Nothing

Set oMsgColl = Nothing

Set oFolder = Nothing



End Sub


Milly Staples said:
The short answer is no, you can't. The longer answer involves the fact that
CDO library is a part of Outlook and Exchange - you cannot distribute the
library without these products per Microsoft Licensing restrictions.

--
Milly Staples [MVP - Outlook]

Post all replies to the group to keep the discussion intact.


Having searched the archives,
Robert <robert_rdk@[email protected]> typed:
| Is itpossible to use the CDO without attaching the *.msg file.
| I'd like to create a standalone app. without using Outlook.
|
| Robert
|
| || Using the Outlook Object Model, no. Using Collaboration Data
|| Objects, yes. (Hint: Attach the *.msg file to a temporary new
|| message. There is a property exposed by the attachment object
|| called source.)
||
|| ||| Is there any way to read the Outlook email header (Internet
||| Header), body and fields from a specific .msg-file (using path to
||| file) through Visual Basic (VB 6 or VB.Net)
|||
|||
||| Thks,
|||
||| Robert
|||
||| robert_rdk@[email protected]
 
Thks Neo !

It looks like the things i need.

Robert


neo said:
If you are looking for a way to export the entire message out to a text file
(e.g. get the rfc2822 stream), you should consider using Redemption
(http://www.dimastr.com/redemption/). Perhaps he will see this question and
post a link to an example on how to use the redemption library to perform
the export on a message.

Robert said:
It is not my intension to distribute the library without these products. (
don't worry ;-)) )

The only reason is that Outlook can't show the complete message source (like
Outlook express).

I think that the only remaining possibility is, creating a macro showing
(and saving as txt-file) the complete message source.



I appreciate it if there is an example and someone will share it.



Now I have this (extracting the header):



Sub ExtractMsgSource()

Dim oSession As MAPI.Session

Dim oFolder As Folder

Dim oMsgColl As Messages

Dim oMessage As Message



' Logon to the MAPI session

Set oSession = New MAPI.Session

oSession.Logon



' Get the Inbox folder and its message collection.

Set oFolder = oSession.GetDefaultFolder(CdoDefaultFolderInbox)

Set oMsgColl = oFolder.Messages



For Each oMessage In oMsgColl

MsgBox oMessage.Fields(&H7D001E) 'Display the header

Next



' Logoff and cleanup

oSession.Logoff

Set oSession = Nothing

Set oMessage = Nothing

Set oMsgColl = Nothing

Set oFolder = Nothing



End Sub


Milly Staples said:
The short answer is no, you can't. The longer answer involves the
fact
that
CDO library is a part of Outlook and Exchange - you cannot distribute the
library without these products per Microsoft Licensing restrictions.

--
Milly Staples [MVP - Outlook]

Post all replies to the group to keep the discussion intact.


Having searched the archives,
Robert <robert_rdk@[email protected]> typed:
| Is itpossible to use the CDO without attaching the *.msg file.
| I'd like to create a standalone app. without using Outlook.
|
| Robert
|
| || Using the Outlook Object Model, no. Using Collaboration Data
|| Objects, yes. (Hint: Attach the *.msg file to a temporary new
|| message. There is a property exposed by the attachment object
|| called source.)
||
|| ||| Is there any way to read the Outlook email header (Internet
||| Header), body and fields from a specific .msg-file (using path to
||| file) through Visual Basic (VB 6 or VB.Net)
|||
|||
||| Thks,
|||
||| Robert
|||
||| robert_rdk@[email protected]
 
Back
Top