ITPub博客

首页 > 应用开发 > > c#获取outlook发件人信息为空

c#获取outlook发件人信息为空

作者:apnic 时间:2019-08-19 09:51:16 0 删除 编辑

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的发件人邮箱地址。一直为空。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1282/viewspace-3129043/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    121
  • 访问量
    792