none
Anyway to get the email message in the format that is usually transmitted? RRS feed

  • Question

  • Suppose I am composing an email with inline images and attachments, I am interested in how that content is transmitted - in other words, I am interested in the actual ascii text that is transmitted over the wire - complete with the headers, mime-types, etc, enveloped by the respective boundaries...

    I am aware outlook has a proprietary *.msg format. Hence say if I've received an email, and, if I click on an email from the outlook client and perform a Save As... operation, I have the option to save it to *.msg format. But on opening that in notepad reveals a lot of binary junk which is impossible to decipher.


    I am a bundle of mistakes intertwined together with good intentions

    Saturday, January 7, 2017 6:56 AM

All replies

  • Hello,

    The MSG file format is described in depth. See [MS-OXMSG]: Outlook Item (.msg) File Format in MSDN.

    Also you can get headers and other information from low-level properties. For example, you can use the PropertyAccessor object for getting property values:

    Sub DemoPropertyAccessorGetProperty() 
     
     Dim PropName, Header As String 
     
     Dim oMail As Object 
     
     Dim oPA As Outlook.PropertyAccessor 
     
     'Get first item in the inbox 
     
     Set oMail = _ 
     
     Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
     
     'PR_TRANSPORT_MESSAGE_HEADERS 
     
     PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
     
     'Obtain an instance of PropertyAccessor class 
     
     Set oPA = oMail.PropertyAccessor 
     
     'Call GetProperty 
     
     Header = oPA.GetProperty(PropName) 
     
     Debug.Print (Header) 
     
    End Sub

    You can try to use any low-level property explorer tool such as MFCMAPI or OutlookSpy. 


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Saturday, January 7, 2017 10:22 PM
  • Neither EML nor MSG file formats are used by Outlook for the email storage. Outlook converts the message to the MIME format when sending through an MSTP server. If it is being sent in the Rich Text format, a TNEF fiel is attached. Whne sending through Exchange, al the relevant properties are set and the message is submitted.

    If you want to see how an email is converted to MIME, play with the native Outlook converter (IConverterSession) in OutlookSpy - select the message that you want to convert, then click IConverterSession on the OutlookSpy ribbon.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, January 9, 2017 5:51 AM
  • I want to "see" the email because I am interested to know how the message is formatted as text...For e.g. images are base64 encoded, attachments too, etc...More specifically I am interested to know what happens if we embed an image in the body

    I am a bundle of mistakes intertwined together with good intentions

    Monday, January 9, 2017 11:36 AM
  • Take a look at IConverterSession in OutlookSpy.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, January 9, 2017 1:40 PM