Find outlook Address book details for an email address

Add-in Express™ Support Service
That's what is more important than anything else

Find outlook Address book details for an email address
 
Spiros Nikolopoulos


Guest


Hi,

Is it possible to find outlook address book details for a given email address (with delphi xe2)?
I have and email selected in outlook explorer and I want detail from address book (if any) Address,phone etc?

Thanks
Posted 03 Dec, 2012 09:46:16 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
Hi Spiros,

I understand you so that you need to get contact detauils for a recipietn (or sender) of an email selected in Outlook. I suppose that the following link provides the main part of the solution: http://outlook-buzz.com/outlook-contacts/AddressEntry-object-vs-Contact-object/0/article/0/34170

That is, you get Recipient.AddressEntry and then use the approach suggested by Ken Slovak to get the EntryId of the contact. To get the corresponding ContactItem, you use Namespace.GetEntryFromId().

Is this what you are looking for?


Andrei Smolin
Add-in Express Team Leader
Posted 03 Dec, 2012 10:43:32 Top
Spiros Nikolopoulos


Guest


Hi Andrei,

I manage to do it using Eugene's example for restrict http://www.add-in-express.com/creating-addins-blog/2011/10/21/outlook-retrieve-contact-items/


    ns := self.OutlookAppObj.GetNamespace('MAPI');
    iFolder := ns.GetDefaultFolder( Outlook2000.olFolderContacts );
    folderItems := ifolder.Items;
    resultItems := folderItems.Restrict('[Email1Address] = "<email-to-find>"');
    counter :=0;mitem:=Nil;
     for i:=1  to  resultItems.Count do
        begin
            mitem := resultItems.Item(i);
            try
              contact := Outlook2000._ContactItem(mitem);
              inc(counter);
            except
              mitem := Nil;
            end;

            mitem := Nil
        end;

Posted 03 Dec, 2012 11:42:54 Top
Andrei Smolin


Add-in Express team


Posts: 18806
Joined: 2006-05-11
Many thanks for posting this!


Andrei Smolin
Add-in Express Team Leader
Posted 04 Dec, 2012 03:57:38 Top