我一直试图找出办法找出WICH邮件的地址一封邮件已被发送到。考虑以下内容:

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”。

如何实现这一目标?

谢谢!

有帮助吗?

解决方案

我假设这是Outlook 2007+。你有没有尝试过地址属性

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top