Link an item to multiple contacts

M

Michele

Hi all.
I am using Oulook 2007.
As explained in Microsoft KB article KB298749 to link a new item to a
contact the next actions have to be done:
1) Create an item, such as a new task or message.
2) In a message, click Options, and then click Contacts. In all other items,
click Contacts.
3) In the Look in box, click the folder that contains the contact to which
you want to link.
4) In the Items box, click the contact or contacts to which you want to link
the item. To select adjacent items, click the first item, press the SHIFT
key, and then click the last item. To select nonadjacent items, click the
first item, press the CTRL key, and then click additional items. To select
all items, click Select All on the Edit menu.

The problem arises when you have contacts with the same name and surname and
you want to link those contacts to the same item. If, as an example, i have
two contacts in my contacts folder and both have name "John" and surname
"Due" (And it could easily happens that two different people have the same
name and surname and obviously i can't save them with a name or a surname
different from their real ones ) and i want to create a new task and link
this task to both "John Due" contacts the links for that task is only made of
one of the "John Due" contacts and that is because, as one can see in outlook
vba "Link" class property, the "Link" class has as its default property the
"Name" property that, in the case of a contact item, is the full name. It
cannot accept as Links two objects with the same name even if the two
contacts are two different contacts in the contacts folder.
How can it be possible to link to the same item more than one contact with
the same name and surname?
Thanks a lot for the help
 
M

Michael Bauer [MVP - Outlook]

The default property of a class has nothing to do with how the data is
stored. If both contacts have the same name but different e-mail addresses,
you can add them without any problem.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 24 Dec 2008 06:27:01 -0800 schrieb Michele:
 
M

Michele

Before say something please test it.
If you have two contacts with the same Full Name and even if they have
different email addresses and you want to link these two contacts to the same
item, you can't. Apparently Oulook lets you do that, in fact you can select
both in the select names dialog and click on apply but only one of them is
entered in the item contacts filed and that's for the reasons i explained in
my first post.
Ciao
 
M

Michael Bauer [MVP - Outlook]

You are the one who's looking for help. Do you think your reaction is
clever?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Mon, 29 Dec 2008 15:46:01 -0800 schrieb Michele:
 
M

Michele

I am sorry, i didn't mean to be rude.
Anyway, did you try and get the same result as me?
thanks
Greeting
 
M

Michael Bauer [MVP - Outlook]

Enter the name (or a part of it) directly into the Contacts textbox, then
press ALT+K to resolve the name. If different contacts meet the criteria, a
dialog comes up from which you can choose only of name. Perform the same
procedure until you've chosen everyone.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>

Am Tue, 30 Dec 2008 08:33:00 -0800 schrieb Michele:
 
M

Michele

Hi Michael.
You suggestion works great. Thanks a lot for your help.
If anyone of you would be interested in doing the same (almost)
programmatically in the next lines i input two examples of
VBA subroutines. I discovered, in fact, that using the code one
expects it should regularly work in adding a "Link" object to
any Outlook item has no the expected result when you add two
contacts with the same "FullName" to an item. In fact if you take
a look at the sub Test_Adding_Two_Links_With_The_Same_FullName()
you understand why (I input some statements at the beginning of
the code). Instead in the sub Rename_Links_Based_On_Custom_FileAs_Field()
you can see how to add a Link (That is a Contact) to an Outlook Item
saving it not with its "FullName" property (as it is saved in the default
way, like in the other sub) but with its "FileAs" property so that
if you add to an item two links(Contacts) with the same "FullName" but with
different "FileAs" values you, this time, the Links.count property
has a correct value of two.
I really would like to receive comments about this.
Thanks a lot to all, first you Michael!
Ciao and happy new year to all!!


Sub Rename_Links_Based_On_Custom_FileAs_Field()
'Statements: You have three contacts in your default contact folder _
(Here referenced by Item(1),Item(2),item(3)) with a custom (unique) "FileAs"
field ( _
input manually by the user or programmatically). _
Item(1) has no item inside its "Links" collection _
Item(2) and item(3) has the same "FullName" (But different "FileAs")
Dim NameSpace As Outlook.NameSpace
Dim Contacts As Outlook.Items
Dim ContactOne, ContactTwo, ContactThree As Outlook.ContactItem
Set NameSpace = Application.GetNamespace("MAPI")
Set Contacts = NameSpace.GetDefaultFolder(olFolderContacts).Items
Set NameSpace = Nothing
'The first Contact in the Contacts Collection of the Contacts
default folder
Set ContactOne = Contacts.Item(1)
'The second Contact in the Contacts Collection of the Contacts
default folder
Set ContactTwo = Contacts.Item(2)
'The third Contact in the Contacts Collection of the Contacts
default folder
Set ContactThree = Contacts.Item(3)
'In the next instruction you force the building of the "FileAs"
field of the _
ContactOne based on your personal customization of the "FileAs"
field. _
If you don't use the next instruction Outlook builds the "FileAs"
field in the _
default way, that is the "Files As" filed is the same as the
"FullName" field. _
The contact "FileAs" field even if in memory and in disk has the
value that _
you input for it, every time it has to be used by Outlook for its
internal _
purposes, like the one of linking a contact to an item, it is
rebuilded in the _
default way (No matter if you set a different option for the "File
As" field _
in the main Outlook options).
ContactTwo.FileAs = ContactTwo.FileAs
ContactThree.FileAs = ContactThree.FileAs
ContactOne.Links.Add ContactTwo
ContactOne.Links.Add ContactThree
ContactOne.Save
'The next message dispalys now the correct _
value that is 2 (And not 1 as Inspector the _
secon sub)
MsgBox (ContactOne.Links.Count)
End Sub


Sub Test_Adding_Two_Links_With_The_Same_FullName()
'Statements: You have three contacts in your default contact folder _
(Here referenced by Item(1),Item(2) and Item(3)). _
Item(2) and item(3) have the same "FullName" but different _
"FileAs" fields and item(1) has no item inside its "Links" collection
Dim NameSpace As Outlook.NameSpace
Dim Contacts As Outlook.Items
Dim ContactOne, ContactTwo, ContactThree As Outlook.ContactItem
Set NameSpace = Application.GetNamespace("MAPI")
Set Contacts = NameSpace.GetDefaultFolder(olFolderContacts).Items
Set NameSpace = Nothing
Set ContactOne = Contacts.Item(1)
Set ContactTwo = Contacts.Item(2)
Set ContactThree = Contacts.Item(3)
ContactOne.Links.Add ContactTwo
ContactOne.Save
'ContactThree has the same "FullName" as ContactTwo
ContactOne.Links.Add ContactThree
ContactOne.Save
'The next message dispalys 1 (And not 2 as it should be)
MsgBox (ContactOne.Links.Count)
End Sub
 

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