【问题标题】:MeetingItem Recipient. How to get email会议项目收件人。如何获取电子邮件
【发布时间】:2020-06-24 18:12:11
【问题描述】:

我发现了一个类似的问题,但对于 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

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

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

    【讨论】:

    • Recipient.Address 返回"/o=POST/ou=Zuerich/cn=Recipients/cn=eicherr".AddressEntry.GetExchangeUser().PrimarySmtpAddress 效果很好。谢谢!
    【解决方案2】:

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

    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
    

    【讨论】:

    • PR_SMTP_ADDRESS 不保证存在。请务必使用 ExchangeUser.PrimarySmtpAddress
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多