确保分发列表中的联系人显示名称和电子邮件地址

如何确保我添加到Outlook通讯组列表中的联系人同时显示名称和电子邮件地址?这些联系人可能不存在于任何其他地址簿中,只存在于通讯组列表中。目前,它们只显示为电子邮件地址(在两列中)。 alt text http://img52.imageshack.us/img52/1804/tempgg.jpg 这大致是我们使用的VBA:
    Do Until RS.EOF

        //here's where we want to inject RS!FirstName, RS!Surname etc
        objRecipients.Add RS!Email
        objRecipients.Resolve

        RS.MoveNext
    Loop


    Set objDistList = contactsFolder.Items.Add("IPM.DistList")
    objDistList.DLName = "Whatever"

    objDistList.AddMembers objRecipients
    objDistList.Save

    etc
    
已邀请:
我认为您必须为每个收件人创建一个ContactItem,以便您可以定义名称。这是一个例子:
Sub testdistlist()

    Dim oRecips As Recipients
    Dim ciDist As DistListItem
    Dim ci As ContactItem
    Dim mi As MailItem

    Set mi = Application.CreateItem(olMailItem)
    Set oRecips = mi.Recipients

    Set ciDist = Application.CreateItem(olDistributionListItem)

    'replace this with your recordset loop
    Set ci = Application.CreateItem(olContactItem)
    ci.FirstName = "John"
    ci.LastName = "Lennon"
    ci.Email1Address = "jlennon@example.com"
    ci.Save

    oRecips.Add ci.FullName

    Set ci = Application.CreateItem(olContactItem)
    ci.FirstName = "Ringo"
    ci.LastName = "Starr"
    ci.Email1Address = "rstarr@example.com"
    ci.Save

    oRecips.Add ci.FullName
    'end replace

    ciDist.AddMembers oRecips

    ciDist.Save
    ciDist.Display
    mi.Close olDiscard

End Sub
    
感谢Dick Kusleika的回答,但Graeme的答案给了我一个想法,可以有一个更简单的方法。 这只是在分发列表的条目中使用尖括号。如在
"Ringo Starr<rstarr@example.com>"
哪个工作得很好。 所以我原来的例子看起来像这样:
objRecipients.Add RS!FullName & "<" & RS!Email & ">"
    

要回复问题请先登录注册