How to keep MAPI properties when processing message data in RFC822 format in an Exchange Server 2007/2010 transport agent? RRS feed

  • Question

  • We are developing an agent listening for the submit or endOfData event from the Exchange Server. Due to various reasons we need to convert the Exchange Mail internally to RFC822 format.
    So our MessageProcessor internally converts the message stream (usually TNEF) into RFC822 format. This means when written our modified content back to ‘e.MailItem’ we write the converted content back.
    It seems that this conversion causes a loss of some MAPI properties of the message.
    When out-of-office-mails are enabled for an account the Exchange Server generates both messages the OOF message for internal recipients and the OOF message external recipients.
    When sending an internal message using voting buttons the message arrives without that voting information.

    void Agent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
                MessageProcessor proc = new MessageProcessor();
                Stream messageContent = e.MailItem.GetMimeReadStream();
                Stream processedMail = proc.ProcessExchangeMessage(messageContent); // internally converts the message to RFC822
                Stream writeStream = e.MailItem.GetMimeWriteStream();

    We also tried a dirty „hack“ using the Exchange Server internal method for converting the message from TNEF to RFC822 “ConvertAnyMimeToMime” from “Microsoft.Exchange.Data.Storage.OutboundConversionOptions”, but using that method causes the same issue.

    Now my idea was cloning all MAPI properties not related to the content of a message and reapply them after writing the RFC822 content back to into e.MailItem.

    Any idea how we can overcome our problems?

    Best regards,
    Harald Binkle

    Exchange Server Toolbox | SmartPOP2Exchange | SpamAssassin
    JAM Software GmbH
    Max-Planck-Str.22 * 54296 Trier * Germany

    Wednesday, September 26, 2012 6:46 AM

All replies

  • Jeeze Harald,

    You're one of the few people who ask even better questions than I do.

    Sorry man I can't (am not allowed to) help you with this one.

    Good luck,

    Scott Quinn | C# developer & messaging specialist (for hire). Contact me at

    • Edited by Scott Quinn Wednesday, September 26, 2012 9:52 AM Typo
    Wednesday, September 26, 2012 9:52 AM
  • Hello Scott,

    after posting this question I implemented a dirty workaround.

    Now I'd like to ged rid of that workaround. Are you still not allowed to discuss this?

    Best regards,
    Harald Binkle

    Exchange Server Toolbox | SmartPOP2Exchange | SpamAssassin
    JAM Software GmbH
    Am Wissenschaftspark.26 * 54296 Trier * Germany

    Monday, July 14, 2014 2:15 PM