outlookvsto

Outlook VSTO add-in get complete original email (headers, body, attachments) as sent by SMTP


Is there a way to get the complete original email message as sent in SMTP DATA?

I can get Outlook email body and bodyHTML, and I can get email headers with PR_TRANSPORT_MESSAGE_HEADERS.

Looking for eg:

Return-Path: <user@domain.com>
Received: from XXX
    by mailbox.domain.com
From: sending user <user@domain.com>
To: receiving user <receiver@otherdomain.com>
Date: Wed, 9 Oct 2024

Hi receiver,

more message contents

Sincerely
sending user

Solution

  • Outlook does not keep the complete MIME source - it is not Outlook's native format; everything is parsed into separate MAPI properties. More than that, in some case (and for some people, most cases) email does not even come in the MIME format, e.g., if a message is sent between two Exchange mailboxes (SMTP won't even be invoked).

    There used to be a debug option (registry, if I remember correctly) that forced the POP3/SMTP provider to log the complete MIME source, but I don't think it works anymore.

    If there is a particular property that you suspect is only available in MIME, take a look at Outlook messages with OutlookSpy (I am its author, click IMessage button) to see all available MAPI properties.