Extract SMTP address from Exchange User in the FROM field of a message

前端 未结 2 1809
长情又很酷
长情又很酷 2021-01-26 17:02

I want to organize messages in folders by domain (and possibly user). I have a script but it can\'t get the SMTP addresses from exchange users. The below code is an excerpt from

2条回答
  •  一个人的身影
    2021-01-26 17:26

    MailItem.Sender.GetExchnageUser().ProimarySmtpAddress should work fine for the EX senders, but your code checks the SenderEmailAddress property instead of SenderEmailType. Change it to

    If obj.SenderEmailType = "EX" Then
    

    You can also check the PR_SENT_REPRESENTING_SMTP_ADDRESS property (DASL name http://schemas.microsoft.com/mapi/proptag/0x5D02001F, use MailItem.PropertyAccessor.GetProperty) before using the MailItem.Sender property (which is more expensive)

提交回复
热议问题