Search code examples
outlookvstooutlook-addin

VSTO Outook: Change the sender text from the inspector window


Is it possible to modify the sender text displayed in the 'From' field within the Outlook inspector window? When you double-click an email in the message list of the explorer, a new window (inspector window) opens where Outlook shows a specific text in the 'From' field. Can this text be changed, and where does Outlook retrieve this information from?


Solution

  • Outlook uses PR_SENDER_EMAIL_ADDRESS / PR_SENDER_NAME / PR_SENT_REPRESENTING_EMAIL_ADDRESS / PR_SENT_REPRESENTING_NAME MAPI properties when displaying the sender name. PR_SENDER_ENTRYID / PR_SENT_REPRESENTING_ENTRYID are used when replying. You can see these (and all other) MAPI properties in OutlookSpy (I am its author - click IMessage button).

    The same properties are used both in the Explorer (where the list of messages is shown) and Inspector. Outlook Object Model exposes these properties through the SenderName / SenderEmailType / SenderEmailAddress properties (read-only) and SentOnBehalfOfName (read-write). You can try to modify the MAPI properties using MailItem.PropertyAccessor.SetProperty, but I don't think it will let you (it considers these properties special and plays a big brother). Redemption (I am also its author) does let you modify these properties either one MAPI property at a time using RDOMail.Fields[] or by setting the RDOMail.Sender / SentOnBehalfOf properties.

    Keep in mind that you cannot temporarily change these properties on the fly - they need to be set, and the message must be saved. The change will then be visible in both Explorer and Inspector.