我在这里看到了一些帖子,人们要求找到收件人的电子邮件地址,并被引用到MAPI属性: SMTP“。然而,正如一些用户指出的那样,并不是所有的MAPI属性都保证在那里。所以我正在寻找一个函数,它可以找到正确的方法来获得这个电子邮件地址。对于发件人的电子邮件地址,我能够判断它是否是exchange用户,并获得http://schemas.microsoft.com/mapi/proptag/0x39FE001E电子邮件地址。有没有一种方法可以在MAPI丢失的情况下返回这个地址?
这是我到目前为止所掌握的
Public Function RecipientSMTPEmailAddress(outRecip As Outlook.Recipient) As String
On Error GoTo MissingMAPIError
RecipientSMTPEmailAddress = outRecip.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E")
Exit Function
MissingMAPIError:
RecipientSMTPEmailAddress = outRecip.Address
End Function
我正在寻找一种类似于用于发送者信息的方法:
If OutMail.SenderEmailType = "EX" Then
SenderInfo = OutMail.Sender.GetExchangeUser.PrimarySmtpAddress
Else
SenderInfo = OutMail.SenderEmailAddress
End If
如果有更好的方法确保我得到SMTP电子邮件地址,我洗耳恭听!
*编辑于2019年9月23日-新的和改进的代码,以捕获所有收件人错误
Public Function RecipientSMTPEmailAddress(outRecip As Outlook.Recipient) As String
On Error GoTo MissingMAPIError
RecipientSMTPEmailAddress = outRecip.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E")
Exit Function
MissingMAPIError:
RecipientSMTPEmailAddress = RecipientSMTPEmailAddressExchange(outRecip)
End Function
Public Function RecipientSMTPEmailAddressExchange(outRecip As Outlook.Recipient) As String
On Error GoTo MissingExchangeError
RecipientSMTPEmailAddressExchange = outRecip.AddressEntry.GetExchangeUser.PrimarySmtpAddress
Exit Function
MissingExchangeError:
RecipientSMTPEmailAddressExchange = ""
End Function
发布于 2019-09-21 04:26:01
如果缺少PR_SMTP_ADDRESS
属性,请使用Recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddrress
(准备好处理空值和异常)。
https://stackoverflow.com/questions/58034692
复制相似问题