How do I programmatically link contact to contact? 
Author Message
 How do I programmatically link contact to contact?

Is there any info out there on how to link a contact item to another contact
item programmatically

--
James LeVieux
Engstrom Design Group
jlevieuxATengstromdesign.com



Sat, 29 Nov 2003 04:02:43 GMT  
 How do I programmatically link contact to contact?
Watch out how you use it.  It will add links of all contacts in the default
folder to the first contact in the folder.

Sub AddLinkTest()
    Dim olNameSpace As Outlook.NameSpace
    Dim olContactFolder As Outlook.MAPIFolder
    Dim olThisContact As ContactItem
    Dim olContact As ContactItem
    Dim olLinks As Links
    Set olNameSpace = Application.GetNamespace("MAPI")
    Set olContactFolder = olNameSpace.GetDefaultFolder(olFolderContacts)
    Set olThisContact = olContactFolder.Items.Item(1)
    Set olLinks = olThisContact.Links
    MsgBox olThisContact.FullName
    For Each olContact In olContactFolder.Items
        If Not olContact.FileAs = olThisContact.FileAs Then
            olLinks.Add olContact
        End If
    Next
    olThisContact.Save
    Set olLinks = Nothing
    Set olContact = Nothing
    Set olThisContact = Nothing
    Set olContactFolder = Nothing
    Set olNameSpace = Nothing
End Sub

HTH
Keith


Quote:
> Is there any info out there on how to link a contact item to another
contact
> item programmatically

> --
> James LeVieux
> Engstrom Design Group
> jlevieuxATengstromdesign.com



Sat, 29 Nov 2003 05:01:29 GMT  
 How do I programmatically link contact to contact?
I seem to always forget something:  it will error if you have Distribution
Lists in the Contacts folder.  You'll have to check for the type of object
in the loop.


Quote:
> Is there any info out there on how to link a contact item to another
contact
> item programmatically

> --
> James LeVieux
> Engstrom Design Group
> jlevieuxATengstromdesign.com



Sat, 29 Nov 2003 05:02:59 GMT  
 How do I programmatically link contact to contact?
The item you add Links to also must have been saved first and there
should be no duplicate Link objects in the Links collection.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> I seem to always forget something:  it will error if you have
Distribution
> Lists in the Contacts folder.  You'll have to check for the type of
object
> in the loop.



Sat, 29 Nov 2003 21:16:40 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Transferring standard contact data from standard contact forms into contact custom forms

2. Adding a contact link in the Links Collection

3. Retreive current contact index from contact form

4. Add Contacts to a PublicFolder Contact list

5. best way to sync Outlook contacts with a SQL Server contacts database

6. Find a contact in Outlook contact or in a access database

7. VBA Display selected contacts/people from a Shared contact list

8. Delete Contacts from "Contact " Folder Automatically

9. Cannot mail to Contacts with modified Contact Form

10. Can Not send Mail to Contacts that use a Modified Contact Form

11. VB send outlook contact to contacts subfolder?

12. From a Contact's details to the Contact folder

 

 
Powered by phpBB® Forum Software