MeetingItem收件人。如何收到电子邮件

时间:2018-05-17 09:26:48

标签: vba outlook-vba

我发现了一个类似的问题,但对于c#Outlook : How to get email from Recipient field? 在这个问题上也没有正确的答案 不过,我尝试了这个帖子的一些答案 recipient.AddressEntry.Address< =返回相同的内容 recipient.Address我到目前为止所使用的内容以及结果后面给我的是什么:

"/o=POST/ou=Zuerich/cn=Recipients/cn=eicherr"

如何获取收件人的电子邮件地址?

我还尝试了.AddressEntry.GetContact().Email1Address.AddressEntry.GetExchangeUser().Address这一切都不适合我。

以下是MSDN文档解释如何获取电子邮件地址但我不知道如何在我的代码中使用它Obtain the E-mail Address of a Recipient

我的代码:

Dim Msg As Outlook.MeetingItem
Set Msg = Item
Set recips = Msg.Recipients
Dim recip As Outlook.Recipient

For Each recip In recips
    Dim email as String
    email = CStr(recip.Address)
    Debug.Print email
End For

2 个答案:

答案 0 :(得分:1)

如果Recipient.AddressEntry.Type <> "EX",请使用Recipient.Adddress。否则使用Recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress

答案 1 :(得分:0)

我插入的链接上的文档最终帮助我解决了这个问题。

For Each recip In recips

    'Obtain the E-mail Address of a Recipient
    Dim pa As Outlook.PropertyAccessor
    Const PR_SMTP_ADDRESS As String = _
        "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
    Set pa = recip.PropertyAccessor

    Dim email as String
    email = CStr(pa.GetProperty(PR_SMTP_ADDRESS))
    Debug.Print email

End For