我使用以下代码获取要发送的邮件的每个收件人的 ContactInfo(在 Outlook2010 中)。该代码有效,但仅适用于少数联系人,尽管所有联系人都存储在我的地址簿中。对于某些人来说,最后一行 (GetContact) 没有提供任何内容。为什么?
' 创建 RDO 会话 Dim session Set session = CreateObject("Redemption.RDOSession")
Set session.MAPIOBJECT = Application.session.MAPIOBJECT
' Get current email
ActiveInspector.CurrentItem.Save ' Necessary to get current status
Dim mail
Set mail = session.GetMessageFromID(ActiveInspector.CurrentItem.EntryID)
' Create salutation line
Dim salutationLine As String
salutationLine = ""
For Each Recipient In mail.Recipients
' Skip CC and BCC addresses
If (Recipient.Type <> olTo) Then GoTo NextRecipient
' Assume standard salutation and use complete name as first name
Dim salutationType As String
salutationType = ""
Dim firstName As String
Dim lastName As String
Dim recipientName As String
recipientName = IIf(Recipient.Name <> "", Recipient.Name, Recipient.Address)
lastName = ""
If InStr(1, recipientName, " ") > 0 Then
firstName = Split(recipientName, " ")(0)
lastName = Split(recipientName, " ")(1)
End If
Dim addressEntry
Set addressEntry = Recipient.addressEntry
If (Not addressEntry Is Nothing) Then
' If we have qualified name information: extract first and last name
If (addressEntry.firstName <> "") Then firstName = addressEntry.firstName
If (addressEntry.lastName <> "") Then lastName = addressEntry.lastName
Dim contactInfo
Set contactInfo = addressEntry.GetContact()
If (Not contactInfo Is Nothing) Then