确保通讯组列表中的联系人同时显示姓名和电子邮件地址

发布于 2024-08-31 13:23:43 字数 671 浏览 6 评论 0原文

如何确保添加到 Outlook 通讯组列表的联系人同时显示姓名和电子邮件地址?这些联系人可能不存在于任何其他地址簿中,仅存在于通讯组列表中。目前,它们仅显示为电子邮件地址(在两列中)。

替代文本 http://img52.imageshack.us/img52/1804/tempgg.jpg< /a>

我们使用的 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

How can I ensure the contacts I add to an Outlook distribution list are displayed with both name and email address? These contacts may not exist in any other address book, just the distribution list. Currently they show up just as an email address (in both columns).

alt text http://img52.imageshack.us/img52/1804/tempgg.jpg

Here's roughly the VBA we're using:

    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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞觅青森が 2024-09-07 13:23:43

我认为您必须为每个收件人创建一个 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 = "[email protected]"
    ci.Save

    oRecips.Add ci.FullName

    Set ci = Application.CreateItem(olContactItem)
    ci.FirstName = "Ringo"
    ci.LastName = "Starr"
    ci.Email1Address = "[email protected]"
    ci.Save

    oRecips.Add ci.FullName
    'end replace

    ciDist.AddMembers oRecips

    ciDist.Save
    ciDist.Display
    mi.Close olDiscard

End Sub

I think you have to create a ContactItem for each recipient so you can define the name. Here's an example:

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 = "[email protected]"
    ci.Save

    oRecips.Add ci.FullName

    Set ci = Application.CreateItem(olContactItem)
    ci.FirstName = "Ringo"
    ci.LastName = "Starr"
    ci.Email1Address = "[email protected]"
    ci.Save

    oRecips.Add ci.FullName
    'end replace

    ciDist.AddMembers oRecips

    ciDist.Save
    ciDist.Display
    mi.Close olDiscard

End Sub
天赋异禀 2024-09-07 13:23:43

感谢 Dick Kusleika 的回答,但 Graeme 的回答给出了我的想法可能有一种更简单的方法。

这只是在通讯组列表的条目中使用尖括号。如 “Ringo Starr[电子邮件受保护]>"

效果很好。

所以我原来的例子看起来像这样:

objRecipients.Add RS!FullName & "<" & RS!Email & ">"

Thanks to Dick Kusleika for his answer but Graeme's answer here gave me an idea there could be an easier way.

And that is just to use angle brackets in the entry to the distribution list. As in "Ringo Starr<[email protected]>"

Which works just fine.

So my original example would look like this:

objRecipients.Add RS!FullName & "<" & RS!Email & ">"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文