'c# find outlook contact by email address

I was able to find outlook conctacts by firstname and lastname this way:

Outlook.ContactItem contact = (Outlook.ContactItem)contactItems.Find(String.Format("[FirstName]='{0}' or "+ "[LastName]='{0}'", namePart));

Now since I am looking for a contact via emailaddress I thought this should work, but it doesn't:

Outlook.ContactItem contact =(Outlook.ContactItem)contactItems.Find(String.Format("[Email1Address]='{0}'", namePart));

But unfortunately it won't find the contact, there is, with the email address passed to the method and filled into namePart.

Can anyone tell me, where my mistake lies? Thanks in advance!



Solution 1:[1]

Are you sure ContactItem.Email1Address has the expected value? Did you make sure of that in OutlookSpy (I am its author)? Select the matching contact, click Item button on the OutlookSpy ribbon, select the Email1Address property.

If you added the contact from GAL, Email1Address will be EX type address, not the (expected) SMTP.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1