Linking Contacts

  • Thread starter Thread starter Lance
  • Start date Start date
L

Lance

Hi all,

On the Outlook contact form, bottom left corner there is a
contacts button that lets you link other contacts to the
contact displayed on the form.

How do I link contacts like this using VBA? I'm trying to
use the add method of the Links property but it is not
working(code below runs from an access database).

Can someone please advise?

Thanks,
Lance


Sub LinkContactTest()

Dim ol As Outlook.Application
Set ol = Outlook.Application

Dim ns As Outlook.NameSpace
Set ns = ol.GetNamespace("MAPI")

Dim fld As MAPIFolder
Set fld = ns.GetDefaultFolder(olFolderContacts)

Dim cnt As Outlook.ContactItem

For Each cnt In fld.Items
If cnt.FullName = "John Smith" Then
cnt.Links.Add ns.GetDefaultFolder
(olFolderContacts).Items(2)
MsgBox ns.GetDefaultFolder
(olFolderContacts).Items(2).FullName
End If

Next
 
Links.Add is the correct method. What precisely isn't working? I don't see any statement that saves the item.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Back
Top