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
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