Add to Distribution List doesn't work

J

John Birtwistle

The code below should add the contact Jeff Smith
(who exists and has a valid email address) to
the distribution list DList.
The list is created but Jeff Smith is not added to it.
Any ideas why code doesn't work ?
No problem doing it manually.

'VB6 and Outlook 2002
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objRcpnt As Outlook.Recipient
Dim objitem As Outlook.DistListItem

Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")

Set objMail = olApp.CreateItem(olMailItem)

Set objRcpnt = objMail.Recipients.Add("Jeff Smith")
Set objitem = olApp.CreateItem(olDistributionListItem)

objitem.AddMember Recipient:=objRcpnt
objitem.DLName = "DList"
objitem.Save

John Birtwistle
 

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