Outlook addin, Set From programmatically (delegation) RRS feed

  • Question

  • Is there anyway to set the from user when creating an outlook.mailitem programmatically? Here is some addin code that creates an outlook mail message:

      Outlook.MailItem mail = this.Application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;

    mail .From = "" // set this

    You can set this property once the email message pops up by just using the drop down From box. However, I need to set this in code. This does require delegation to be setup correctly.

    We are using Microsoft hosted exchange.




    Sunday, October 13, 2013 6:02 PM


  • If you are sending through Exchange, you need to set the MailItem.SentOnBehalfOfName property. You must have an explicit permission to send on behalf of that user.

    If you are sending through a preconfigured account, set the MailItem.Account property to one of the Account objects from the Namespace.Accounts collection.

    If you want to send through SMTP on behalf of an arbitrary address, you will need to set a special named property using MailItem.PropertyAccessor.SetProperty  - see

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, October 13, 2013 8:03 PM