Finding a corresponding contact item from a recipient entryid

  • Thread starter Thread starter Stefan
  • Start date Start date
S

Stefan

I have to find a contact corresponding to a recipient in an outlook
task item. Once I found a function GetContactEntryID that maps an
recipient entryId to a contact by truncating and converting the id.
This worked fine until now but with OL2003/Ex2003/WinXP SP2 it seems
to not work any more.
In newsgroups, I have also found many advices to make a search or
restrict on the contact items by the email address or the name but
this is not enough for me: the name or email address of the contact
could have changed in the meantime. I assume that there has to be a
reliable solution since also Outlook can do this: a doubleclick on a
recipient in a mail message takes me to the corresponding contact even
if I changed name/email of this contact.
Any ideas around?
Thanks very much for any help.
Stefan
 
Look at that function's source code and see what fails by comparing what it
produces with what it must produce.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Dmitri
I've included the function's source code below. In my example the
variable fBytes gets a value of 1.953658E+09 so GetContactEntryID
always is an empty string.

Stefan

Public Function GetContactEntryID(AddressEntryId As String) As String
On Error GoTo ErrorHandler

Dim sAddressEntryID As String
Dim sBytes As String
Dim fBytes As Single

GetContactEntryID = ""
sAddressEntryID = AddressEntryId
If Len(sAddressEntryID) >= 72 Then
sBytes = Mid$(sAddressEntryID, 65, 8)
fBytes = 0
fBytes = fBytes + (Val("&H" & Mid$(sBytes, 1, 2)))
fBytes = fBytes + (Val("&H" & Mid$(sBytes, 3, 2)) * (2 ^ 8))
fBytes = fBytes + (Val("&H" & Mid$(sBytes, 5, 2)) * (2 ^ 16))
fBytes = fBytes + (Val("&H" & Mid$(sBytes, 7, 2)) * (2 ^ 24))
If Len(sAddressEntryID) >= (72 + (fBytes * 2)) Then
GetContactEntryID = Mid$(sAddressEntryID, 73, fBytes * 2)
End If
End If
Exit Function

ErrorHandler:

GetContactEntryID = ""

End Function
 
Ok, and when you step through the function when running under Outlook 2003,
what is different compared to the same address entry's entryid under Outlook
2002?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Here's a working example:
sAddressEntryID:
00000000FE42AA0A18C71A10E8850B651C24000003000000040000000000000046000000000000004FE5D0522F4EB648B4A39E1DFA72F58D0700AE8EBDE02BF08D4FA2EF19D6B94F069000000001EB250000A7FA4349428AE448AE43535670036F2C000000CF000B0000000000

fbytes gets a value of 70 and
so GetContactEntryID gets a value of:
000000004FE5D0522F4EB648B4A39E1DFA72F58D0700AE8EBDE02BF08D4FA2EF19D6B94F069000000001EB250000A7FA4349428AE448AE43535670036F2C000000CF000B0000


in a non working examples I get for
sAddressEntryID:
00000000812B1FA4BEA310199D6E00DD010F5402000001104D75737465722C204B75727400534D5450006B756D75407A69636B2E636800

fbytes then gets 1.953658E+09 resulting in an empty GetContactEntryId

And I'm not really sure about the "working" environment. I traced both
examples with Outlook 2003, but the first was created maybe with
Outlook 2002. But for sure, all newly created contacts don't work.

Any idea? You need more info?

Thanks, Stefan
 
What I mean is take the address entry entryid and the corresponding
ContactItem entryid and compare the two to see what you need to delete
(prefix and suffix) from the address entry entryid.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
That's my problem: I don't see any match between the two id's. Look at the
second example where the address entryid is

00000000812B1FA4BEA310199D6E00DD010F5402000001104D75737465722C204B75727400534D5450006B756D75407A69636B2E636800

The corresponding ContactItem's entryid is as follows:

000000004FE5D0522F4EB648B4A39E1DFA72F58D0700AE8EBDE02BF08D4FA2EF19D6B94F069000000001EB250000A7FA4349428AE448AE43535670036F2C000000CF000C0000

So there is obviously no prefix or suffix to delete as in example 1...
 
Hmmm... and you got both entry ids in the same Outlook session on the same
machine, right? I certainly don't see the same behavior in Outlook 2003,
whether it is running using PST or Exchange.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
I think I've found the cause for this bivalent behaviour: The "not working"
example is a contact that is created in Outook object model using a custom
contact form. On this form there is a list for defining of the family
members. These are then created using cdo. And the such created entry ids
are "working" as usual.
 
Back
Top