0
我使用以下代码来获取要发送的每个邮件收件人的ContactInfo(在Outlook2010中)。代码工作,但只适用于少数联系人,尽管所有联系人都存储在我的adressbook中。对于一些最后一行(GetContact)没有提供。为什么?使用Redemption(Outlook 2010)获取邮件的每个收件人的ContactInfo
“创建RDO会话 昏暗会话 设置会话=的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
对不起,我上面的代码试图在新的邮件上发送这个邮件。因此,我们不是在讨论传入的电子邮件,而是在谈论传出的电子邮件 – user668338
如果您手动输入地址或使用了自动填充,而不是点击“收件人”按钮并选择其中一个联系人,则仍然可以获得一次性条目ID。 –