我已经尝试使用mailItem.SenderEmailAddress和mailItem.Sender.Address,但他们都返回一个字符串,它看起来像这样:
/O=DOMAINNAME/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHI43SPCLT)/CN=RECIPIENTS/CN=JOE BLOGGS8C3
实际上我想要joebloggs@domainname.co.uk重新开始.
有人有主意吗?
非常感谢你.
编辑:我做了一些挖掘; 它适用于"SenderEmailType"SMTP的电子邮件地址,它只适用于Exchange电子邮件地址.
编辑2:我已经尝试了这里指定的代码,但我认为它已经过时了,因为它抛出了"无法创建Active-X组件"错误.
编辑3: 对于任何遇到与我相同问题的人,我找到了答案(在C#中,转换为VB.NET,但仍然有效):
Private Function GetSenderSMTPAddress(mail As Outlook.MailItem) As String
Dim PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
If mail Is Nothing Then
Throw New ArgumentNullException()
End If
If mail.SenderEmailType = "EX" Then
Dim sender As Outlook.AddressEntry = mail.Sender
If sender IsNot Nothing Then
'Now we have an AddressEntry representing the Sender
If sender.AddressEntryUserType = Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry OrElse sender.AddressEntryUserType = Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry Then
'Use the …Run Code Online (Sandbox Code Playgroud)