我一直试图找出一种方法来查找已发送邮件的邮件地址。请考虑以下事项:
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”。
我怎样才能做到这一点?
谢谢!
答案 0 :(得分:6)
我认为这是Outlook 2007+。你试过Address Property吗?
For Each Recipient In mai.Recipients
MsgBox Recipient.Address
Next Recipient
这应该打印每个收件人的电子邮件地址。