if (mail.SenderEmailType == "EX")
{
Outlook.AddressEntry sender = mail.Sender;
if (sender != null)
{
//Now we have an AddressEntry representing the Sender
if (sender.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry
|| sender.AddressEntryUserType == Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
//Use the ExchangeUser object PrimarySMTPAddress
Outlook.ExchangeUser exchUser = sender.GetExchangeUser();
if (exchUser != null)
{
return exchUser.PrimarySmtpAddress; //debug定位到此处获取为空
}
else
{
return null;
}
}
else
{
return sender.PropertyAccessor.GetProperty(PR_SMTP_ADDRESS) as string;
}
}
else
{
return null;
}
}
return exchUser.PrimarySmtpAddress; //debug定位到此处获取为空,什么情况下才会出现获取exchange用户为空呢?
本地测试时正常,但是到了客户端,就一直获取不到Exchange的发件人邮箱地址。一直为空。
reinstall and reset the client outlook ,then this problem can be solved.