【问题标题】:Getting mailaddresses out of recipients of an mailItem从 mailItem 的收件人中获取邮件地址
【发布时间】:2021-04-30 00:11:00
【问题描述】:

我一直在尝试找出一种方法来找出邮件已发送到哪些邮件地址。考虑以下几点:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim mai As MailItem
    Dim intInitial As Integer
    Dim intFinal As Integer
    Dim strEntryId As String
    Dim intLength As Integer
    
    intInitial = 1
    intLength = Len(EntryIDCollection)
    intFinal = InStr(intInitial, EntryIDCollection, ",")
    Do While intFinal <> 0
        strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intFinal - intInitial))
        Set mai = Application.Session.GetItemFromID(strEntryId)
        intInitial = intFinal + 1
        intFinal = InStr(intInitial, EntryIDCollection, ",")
    Loop
    strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intLength - intInitial) + 1)
    MsgBox strEntryId
    Set mai = Application.Session.GetItemFromID(strEntryId)
    For Each Recipient In mai.Recipients
        MsgBox Recipient
    Next
End sub

在那些 msgBoxes 中,我得到了“好名字”,比如“John Doe”——但我想得到邮件地址,“john.doe@gmail.com”。

我怎样才能做到这一点?

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    我假设这是 Outlook 2007+。你试过Address Property吗?

    For Each Recipient In mai.Recipients
      MsgBox Recipient.Address
    Next Recipient
    

    这应该打印每个收件人的电子邮件地址。

    【讨论】:

    • 这是一个正确的假设。我正在使用 Outlook 2010。我将立即对此进行测试。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    相关资源
    最近更新 更多