I am retrieving, this mailItem in compose mode, But when I check for the mailItem.SenderEmailAddress, it is NULL, but all other properties have values there (Ex:- body, body format, to, .... ). How I get the sender email FROM THE MAIL-ITEM IT-SELF?
I am using Visual Studio 2013 with Addin express v.7.7.4087
Here is the code :-
Outlook.Inspector currentInspector = null;
Outlook.MailItem mailItem = null;
Outlook.Folder outboxFolder = null;
Outlook.Recipients recipients = null;
const string PR_SMTP_ADDRESS = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
currentInspector = Globals.ObjOutlook.ActiveInspector();
if (currentInspector != null)
{
if (currentInspector.CurrentItem is Outlook.MailItem)
{
mailItem = currentInspector.CurrentItem as Outlook.MailItem;
mailItem.Save();
string sender = mailItem.SenderEmailAddress; //This is null
}
}
P.S I have to deal with multiple mail boxes. so, I can't get current users address using Namespace. It always return me the address of primary mail box user.
Please see following screen shot
Thanks in advance.
Kushan Randima
Are you sending using multiple Exchange accounts? Use MailItem.SendUsingAccount, then read Account.SmtpAddress. If it is "", use Account.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress.
If MailItem.SendUsingAccount == null, you can assume the default account.