How to visually alter the MailItem SentOnBehalfOf? RRS feed

  • Question

  • Hello

    I'm trying to alter the From Address with an VSTO plugin written in VB.Net

    I need to set the SentOnBehalfOf property in the MailItem.Open event for a new Email. This works fine, mails are actually sent with the correct from address. But when composing a new mail after the first one the value on the FROM address resorts back to the default sender address. (still works in the background though)

    My code is as follows:

    Dim myRecipient = mailItem.Recipients.Add(My.Settings.MailFromAddress)
    mailItem.PropertyAccessor.SetProperty(PR_SENT_REPRESENTING_EMAIL_ADDRESS, My.Settings.MailFromAddress)
    mailItem.PropertyAccessor.SetProperty(PR_SENT_REPRESENTING_NAME, My.Settings.MailFromAddress)
    mailItem.PropertyAccessor.SetProperty(PR_SENT_REPRESENTING_ADDRTYPE, "SMTP")
    mailItem.PropertyAccessor.SetProperty(PR_SENT_REPRESENTING_ENTRYID, mailItem.PropertyAccessor.StringToBinary(myRecipient.AddressEntry.ID))
    I have the feeling PR_SENT_REPRESENTING_ENTRYID is not doing anything whatsoever. If I remove it from my code nothing changes.

    How can I adjust the sender address visually within Outlook?

    Thank you very much for your help.

    • Edited by 1299_ Sunday, February 17, 2019 6:05 PM
    Sunday, February 17, 2019 6:04 PM

All replies