0
votes

I am struggling a bit on how to set the sender address on an outlook mailitem, for an outlook plu-in we have developed. Couln't find any working examples. I am able to set all the mail parts with below code sample. Except the sender details. I want to send out the email from using a different account on the exchange, for which I have a user ID (email-id) and password Eg : [email protected] / Password123. Can you guide me on how I can set these details as sender.

Outlook.MailItem mailItem = this.OutlookItem as Outlook.MailItem;

            mailItem.Subject = "Follow Up : Level ";

            mailItem.HTMLBody = "<html><div style='font-size:10.5px; font-family:Tahoma;'>" + GetSummaryTable().ToString() + "</div></html>" + mailItem.HTMLBody;

            mailItem.To = string.Join(";", new List<string>(MailToList.Distinct()));
            mailItem.CC = string.Join(";", new List<string>(MailCCList.Distinct()));


            mailItem.Importance = OlImportance.olImportanceHigh;
1

1 Answers

1
votes

The best you can do is set the MailItem.SentOnBehalfOfName property. You must have an explicit permission to send on behalf of that user (send-as right).

Otherwise you'd need to create a profile that points to the mailbox of the other user and use that profile instead in Outlook.

If you know the credentials of another user, you can use Redemption and its RDOSession.LogonHostedExchangeMailbox to connect to the other user's mailbox and create and send an email from that temporary profile.