Best stratgey for reading Outlook Contacts with Redemption

  • Thread starter Thread starter Mike V
  • Start date Start date
M

Mike V

I have an application which integrates with Outlook using the
Redemption.dll

Currently when a user enters a string the program searches the users
Outlook contact folder using the Outlook.MAPIFolder.Item.Restrict
method so that a typical query would be:

"[MessageClass]='IPM.Contact' AND [FileAs] >= '" + sSearchFor + "' AND
[FileAs] < '" + sSearchFor + "z'"

Generally this works fine so long as the user is using the standard
Contact form.

The problem I am having is that if a user has a custom contact form
then the message class could be 'IPM.Contact.MyCustomContact' in which
case my application will not find anything.

I could omit the [MessageClass] clause all together, accept that if a
user has a group or some other message type in the contact folder, such
as a Contact Group, then that would cause my application to choke on
that entry.

Now I could fairly easily add a field to the my apps program settings
that would allow a user to specify a custom contact Message Class so
that my restrict clause would be
[MessageClass]='IPM.Contact.MyCustomContact', but my problem with that
is the user could potentially have multiple contact form types in their
Contact folder, so I would still be missing out on some contacts.

So the question is what is the best way to select only contacts but not
exclude custom contact types?
 
if a
user has a group or some other message type in the contact folder, such
as a Contact Group, then that would cause my application to choke on
that entry.

It won't choke if you Dim your basic item as Object and check the Class
property of the item before you perform any contact-specific operations.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Mike V said:
I have an application which integrates with Outlook using the
Redemption.dll

Currently when a user enters a string the program searches the users
Outlook contact folder using the Outlook.MAPIFolder.Item.Restrict
method so that a typical query would be:

"[MessageClass]='IPM.Contact' AND [FileAs] >= '" + sSearchFor + "' AND
[FileAs] < '" + sSearchFor + "z'"

Generally this works fine so long as the user is using the standard
Contact form.

The problem I am having is that if a user has a custom contact form
then the message class could be 'IPM.Contact.MyCustomContact' in which
case my application will not find anything.

I could omit the [MessageClass] clause all together, accept that if a
user has a group or some other message type in the contact folder, such
as a Contact Group, then that would cause my application to choke on
that entry.

Now I could fairly easily add a field to the my apps program settings
that would allow a user to specify a custom contact Message Class so
that my restrict clause would be
[MessageClass]='IPM.Contact.MyCustomContact', but my problem with that
is the user could potentially have multiple contact form types in their
Contact folder, so I would still be missing out on some contacts.

So the question is what is the best way to select only contacts but not
exclude custom contact types?
 
An alternative, since the OP is using Redemption anyway, is to use a
MAPITable filter. A RES_AND could be used with one clause being for message
class with a substring + ignore case for "IPM.CONTACT" and another clause
for the other restriction conditions.

That would return only all contacts no matter if standard or custom and
would be much faster than an Outlook restriction.
 
Back
Top