English 中文(简体)
获取邮件收件人的邮件地址
原标题:Getting mailaddresses out of recipients of an mailItem
  • 时间:2012-05-22 16:15:31
  •  标签:
  • vba
  • outlook

我一直在寻找办法找出寄往哪个邮件的邮件地址。 考虑以下各点:

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" - 但我想要得到邮件地址, " [email protect]

我如何才能做到这一点?

最佳回答

我想这是Outlook 2007+。您是否尝试过 Address Property ?

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

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

问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签