none
[E2016][TS][C#] Message (application/ms-tnef) intercepted in Transport Agent. How to open in Outlook? RRS feed

  • Question

  • Hi.

    We have written a Transport Agent which writes certain mails to the file system.

    This happens in the RoutingAgent's OnCategorizedMessage method:

    using (FileStream fsFileStream = new FileStream(filename, FileMode.Create))
    {
        Stream stream = e.MailItem.GetMimeReadStream();
        stream.CopyTo(fsFileStream);
    }

    An example file looks like this:

    Received: from EXCHANGE.HS.local (192.168.0.15) by Exchange.HS.local
     (192.168.0.15) with Microsoft SMTP Server (TLS) id 15.1.225.42; Thu, 29 Mar
     2018 19:30:57 +0200
    Received: from EXCHANGE.HS.local ([::1]) by Exchange.HS.local ([::1]) with
     mapi id 15.01.0225.041; Thu, 29 Mar 2018 19:30:57 +0200
    Content-Type: application/ms-tnef; name="winmail.dat"
    Content-Transfer-Encoding: binary
    From: ivap <ivap@hs.local>
    To: Norbert Harrer <Norbert@hs.local>
    Subject: AW: t2
     4 - Routed - BIG BROTHER IS WATCHING 4 - Routed
    Thread-Index: AQHTx4M/J13BZnCEcEK8N0TKNx1r0qPneFjN
    Date: Thu, 29 Mar 2018 19:30:57 +0200
    Message-ID: <f6eb6125e510496da0784d29b110fe6e@hs.local>
    References: <0d2f1b32383f46c891dc68650d260399@hs.local>,<cada838db81e47f1ac3a42354edbdfee@hs.local>
    In-Reply-To: <cada838db81e47f1ac3a42354edbdfee@hs.local>
    Accept-Language: de-AT, de-DE, en-US
    Content-Language: de-AT
    X-MS-Has-Attach:
    X-MS-Exchange-Organization-SCL: -1
    X-MS-TNEF-Correlator: <f6eb6125e510496da0784d29b110fe6e@hs.local>
    MIME-Version: 1.0
    X-MS-Exchange-Organization-Processed-By-MBTSubmission:
    X-MS-Exchange-Organization-OriginalSize: 7795
    X-MS-Exchange-Organization-OriginalArrivalTime: 29 Mar 2018 17:30:57.4554
     (UTC)
    X-MS-Exchange-Organization-MessageSource: StoreDriver
    X-MS-Exchange-Organization-FromEntityHeader: Hosted
    X-MS-Exchange-Organization-MessageDirectionality: Originating
    X-MS-Exchange-Organization-Id: 00000000-0000-0000-0000-000000000000
    X-MS-Exchange-Organization-AuthSource: Exchange.HS.local
    X-MS-Exchange-Organization-AuthAs: Internal
    X-MS-Exchange-Organization-AuthMechanism: 04
    X-MS-Exchange-Organization-BCC:
    X-MS-Exchange-Organization-OriginalClientIPAddress: 10.0.0.10
    X-Originating-IP: [10.0.0.10]
    X-MS-Exchange-Organization-OriginalServerIPAddress: 192.168.0.15
    X-MS-Exchange-Organization-SubmissionRecipientCount: 1
    X-MS-Exchange-Organization-Network-Message-Id: 35bb2dda-6f5b-471f-2a57-08d5959ad519
    X-MS-Exchange-Organization-OrderedPrecisionLatencyInProgress: LSRV=EXCHANGE.HS.local:TOTAL-SUB=0.093|SA=0.078|MTSS-PEN=0.022(MTSSD-PEN=0.022(MTSSDA=0.005|MTSSDC=0.006));2018-03-29T17:30:57.549Z
    Return-Path: ivap@hs.local
    X-MS-Exchange-Forest-ArrivalHubServer: EXCHANGE.HS.local
    X-MS-Exchange-Organization-Cross-Premises-Headers-Processed: Exchange.HS.local
    X-MS-Exchange-Organization-HygienePolicy: Standard
    X-MS-Exchange-Organization-MessageLatency:
    	SRV=EXCHANGE.HS.local:TOTAL-SUB=0.111|SA=0.078|MTSS-PEN=0.033(MTSSD-PEN=0.033(MTSSDA=0.005|MTSSDC=0.006|SDSSO-PEN=0.011
     (SMSC=0.007|MTSSDM-PEN=0.003)))
    X-MS-Exchange-Organization-AVStamp-Enterprise: 1.0
    X-MS-Exchange-Organization-Recipient-Limit-Verified: True
    X-MS-Exchange-Organization-TotalRecipientCount: 1
    X-MS-Exchange-Organization-Transport-Properties: DeliveryPriority=Normal
    X-MS-Exchange-Organization-Prioritization: 1
    X-MS-Exchange-Forest-IndexAgent-0:
    	AQ7QAVJldHJpZXZlck9wZXJhdG9yLDEwLDA7UmV0cmlldmVyT3Blcm
     F0b3IsMTEsMTtQb3N0RG9jUGFyc2VyT3BlcmF0b3IsMTAsMDtQb3N0
     RG9jUGFyc2VyT3BlcmF0b3IsMTEsMDtQb3N0V29yZEJyZWFrZXJEaW
     Fnbm9zdGljT3BlcmF0b3IsMTAsMjQ7UG9zdFdvcmRCcmVha2VyRGlh
     Z25vc3RpY09wZXJhdG9yLDExLDA7VHJhbnNwb3J0V3JpdGVyUHJvZH VjZXIsMjAsNzk=
    X-MS-Exchange-Forest-IndexAgent: 1 212
    X-MS-Exchange-Forest-EmailMessageHash: A6A36EB5
    X-MS-Exchange-Organization-Processed-By-Journaling: Journal Agent
    
    <binary data removed>

    Our goal is to produce a file which can be opened in Outlook. If I naively rename the file to something.eml, and open it in Outlook, then there is no body visible. I guess the eml file is expected to be in mime format.

    I researched a while and found two facts where I am not sure if they are really true:

    • Converting the tnef format to mime is hard, maybe even impossible.
    • Outlook should be able to handle tnef.

    Ideally I would prefer to end up with an Outlook MSG file. But any other solution to get Outlook to view the file might also be sufficient. Any ideas?

    Thanks,
    Norbert


    • Edited by Coder_N Friday, March 30, 2018 7:09 AM
    Thursday, March 29, 2018 6:04 PM