I have a VSTO Outlook 2007 add-in. I am trying to get sender e-mail address when new email comes to Inbox.
To do it I use the following code:
void inbox
In Outlook 2007 you can do it like this:
private string GetSmtpAddress(Outlook.MailItem oItem)
{
Outlook.Recipient recip;
Outlook.ExchangeUser exUser;
string sAddress;
if (oItem.SenderEmailType.ToLower() == "ex")
{
recip = Globals.ThisAddIn.Application.GetNamespace("MAPI").CreateRecipient(oItem.SenderEmailAddress);
exUser = recip.AddressEntry.GetExchangeUser();
sAddress = exUser.PrimarySmtpAddress;
}
else
{
sAddress = oItem.SenderEmailAddress.Replace("'", "");
}
return sAddress;
}