I encountered the same issue when accessing the sender email address for an Outlook mail item. To avoid a "security warning", do not create a new application object, use Globals.ThisAddIn.Application instead to create a new mail file.
string GetSenderEmail(Outlook.MailItem item) { string emailAddress = ""; if (item.SenderEmailType == "EX") { Outlook.MailItem tempItem = (Outlook.MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem); tempItem.To = item.SenderEmailAddress; emailAddress = tempItem.Recipients[1].AddressEntry.GetExchangeUser().PrimarySmtpAddress.Trim(); } else { emailAddress = item.SenderEmailAddress.Trim(); } return emailAddress; }
kumar Jul 28 '09 at 22:55 2009-07-28 22:55
source share