Linking Contacts

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
 
S

Sue Mosher [MVP]

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
 

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