次のコードを使用して、送信するメールの各受信者の ContactInfo (Outlook2010) を取得します。すべての連絡先は私のアドレス帳に保存されていますが、コードは機能しますが、少数の連絡先に対してのみ機能します。一部の場合、最後の行 (GetContact) は何も配信しません。なんで?
' RDO セッションを作成 Dim セッション 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