Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Links collection issue with a distributed list in Outlook 2000 1

Status
Not open for further replies.

MmEe

MIS
Jan 22, 2002
2
GB
Please can anyone tell me if it is possible to you the links collection with a distribution list. I am trying to programatically add an existing contact to an existing distribution list using this code:

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myDistList As Outlook.DistListItem
Dim myContact As Outlook.ContactItem

Set myDistList = myOlApp.CreateItem(olDistributionListItem)
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder_(olFolderContacts)
tempstr = InputBox("Enter the name of the contact to link_ to this task")
If tempstr <> &quot;&quot; Then
tempstr = &quot;[Full Name] = &quot;&quot;&quot; & tempstr & &quot;&quot;&quot;&quot;
Set myItems = myFolder.Items.Restrict(&quot;[MessageClass]_ = 'IPM.Contact'&quot;)
Set myContact = myItems.Find(tempstr)

myDistList.Links.Add myContact

myDistList.Display

This creates a distribution list but does not add the existing contact??

After looking high and low, i have not found any this to say this is not possible.

Please help

Regards
Mark
 
Hi MmEe,
I'm not sure about the exact solution (that would take a lot more time), but it looks like, instead of creating a new distribution list, you want to first get an existing distribution list:

(copied from help file where &quot;Project Team&quot; is the name of the dist list.)
Set myOlApp = CreateObject(&quot;Outlook.Application&quot;)
Set myNamespace = myOlApp.GetNamespace(&quot;MAPI&quot;)
Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts)
myFolder.Display
Set myItem = myFolder.Items(&quot;Project Team&quot;)


Then add the contact to the Links-collection property of the dist list object? So something like:
myDistList.Links.Add(myContact)

Not tested, and there's a disturbing note in the helpfile about the Links property that says, &quot;Read-only,&quot; so maybe this is the wrong direction. But it may be worth a try.. Katie
Hi! I'm currently studying the COM+ programming model. Hopefully YOU'RE having fun, which would make one of us..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top