DistListItems and Recipients

R

Rodrigo

HI! Please Forgive my english!!! :D

I need to create a Distribution list with some contacts in a public folders.
This contacts are market in several categories. I need to create one
distribution list for each categories i have.

When i create the distribution list and use the method "AddMember", only
Name and SMTP address are stored in Distribution List. but... can i link
the vcard of the contacts as are linked with "Select Members" buttons in
Distribution List Window?

This is the "beta" script

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myContactFolder As Outlook.MAPIFolder
Dim myDistList As Outlook.DistListItem
Dim myTempItem As Outlook.MailItem
Dim myRecipients As Outlook.Recipients


Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myTempItem = myOlApp.CreateItem(olMailItem)

Set myDistList = myOlApp.CreateItem(olDistributionListItem)

Set myRecipients = myTempItem.Recipients
SeleccionarContactFolder:
Set myContactFolder = myNameSpace.PickFolder
myDistList.DLName = TextBox1.Text


If myContactFolder.DefaultItemType <> olContactItem Then
MsgBox ("Please Select a contact Folder")
GoTo selectContactFolder:
End If
Dim myContact As Outlook.ContactItem
Dim myContactItems As Outlook.Items

Debug.Print (myContactFolder.Items.Count)

Set myContactItem = myContactFolder.Items

On Error goto Error_Handler
For Each myContact In myContactItem
If myContact.Email1Address <> "" Then
myRecipients.Add myContact.Email1Address
Debug.Print (" Name" & myContact.FullName & ", categories " &
myContact.Categories )
myDistList.AddMembers myRecipients
End If
Skip_section:
Next

myDistList.Subject = TextBox1.Text
showContactProgress.Visible = False
myDistList.Display
showContactProgress.Visible = True
myDistList.Save
Exit Sub

Error_handler:
Resume Skip_section



Thanks in Advance!

Rodrigo de los Santos

delossantos at ineba dot net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top