Create Mail Sender

I am creating an email object in Outlook 2013, but I cannot find how to create a Sender object. I am using this code:

Outlook.MailItem mail = (Outlook.MailItem)
         Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
mail.To = "mail@gmail.com"
mail.Sender = // What goes here?
mail.Subject = "Mail subject";

A Sender object is an implementation of an interface Outlook.AddressEntry, so there must be an implementation somewhere, but where? Is it possible to create this sender object?

BTW, the sender of the letter does not need an account registered in Outlook, so I can not use the property for this mail.SendUsingAccount.

+4
source share
2 answers

Thanks to Dmitry Streblechenko for his comments above, I can get an answer, and these are the lines for creating AddressEntryand assigning it Sender:

Outlook.MailItem mail = (Outlook.MailItem) Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
Outlook.Recipient recipient = Globals.ThisAddIn.Application.Session.CreateRecipient("mymail@domain.com");
mail.Sender = recipient.AddressEntry;
+7
source

Outlook.MailItem.Sender .

, Outlook , AddressEntry , CurrentUser .

: http://msdn.microsoft.com/en-us/library/office/ff869056.aspx

+1

All Articles