Providing contacts in the distribution list is displayed with the name and email address

How can I ensure that the contacts I add to the Outlook Distribution List appear with both name and email address? These contacts may not appear in any other address book, only on the distribution list. They are currently displayed 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 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

      

+2


a source to share


2 answers


Thanks to Dick Kuslaika for his answer, but Graham's answer here gave me an idea what could be easier.

And it's easy to use angle brackets in the mailing list entry. As in"Ringo Starr<rstarr@example.com>"

Which works just fine.



So my original example would look like this:

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

      

+1


a source


I think you need to create a ContactItem for each recipient so that 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 = "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

      

+1


a source







All Articles