Getting an AddressEntry by Name

R

Ra

I am having a weird problem getting an AddressEntry object for a person's name.
I'm using the Outlook 11 Interop object and the code is somthing like this:

AddressList oAL = oNS.AddressLists["Global Address List"];
AddressEntries oAEs = oAL.AddressEntries;

//loop through list and find corresponding address entries
foreach (string name in lstNames) //lstname is a list of
strings
{
AddressEntry oAE = oAEs[name];
....

The Addressentry object returned is not what is expected, but the debugger
shows the correct entry for oAEs[name]. Weird! What is going on here?

Is there a better way to get an Addressentry for a given name?
Any suggestions?
Eventually I do a getFreeBusy for that entry, so even an alternate route is
fine.

Thanks,
Ra
 
D

Dmitry Streblechenko

Try to use Namespace.CreateRecipient(name). You can then call
Recipient.Resolve, then access Recipient.AddressEntry property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
R

Ra

Thanks a lot Dmitry. That works perfect for an exact name match. Now I need
to try the edge conditions and see how the resolution works.

-Ra

Dmitry Streblechenko said:
Try to use Namespace.CreateRecipient(name). You can then call
Recipient.Resolve, then access Recipient.AddressEntry property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Ra said:
I am having a weird problem getting an AddressEntry object for a person's
name.
I'm using the Outlook 11 Interop object and the code is somthing like
this:

AddressList oAL = oNS.AddressLists["Global Address List"];
AddressEntries oAEs = oAL.AddressEntries;

//loop through list and find corresponding address entries
foreach (string name in lstNames) //lstname is a list of
strings
{
AddressEntry oAE = oAEs[name];
...

The Addressentry object returned is not what is expected, but the debugger
shows the correct entry for oAEs[name]. Weird! What is going on here?

Is there a better way to get an Addressentry for a given name?
Any suggestions?
Eventually I do a getFreeBusy for that entry, so even an alternate route
is
fine.

Thanks,
Ra
 

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