How to do address lookup in c#

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

How to do address lookup in c#
 
Bob Milani


Guest


Hi,

I am trying to find out in c# to do a lookup of a typed address like "John smith" on the global address list and return a recipient. I know there is a c++ method called "HrGWResolveAddress". How can I get access to this method? Which dll do I have to use? Or is there an easier way.

Thanks,
Bob
Posted 27 Jan, 2005 03:14:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Bob,

I think you should use the Mapi32.dll. You can find rich information about Microsoft MAPI in the MSDN. To import functions from Mapi32.dll you should use DllImport attribute in C#.
For example:
[DllImport("MAPI32.DLL", CharSet=CharSet.Ansi, EntryPoint="HrGetOneProp@12")]
public static extern void HrGetOneProp(IntPtr pmp, uint ulPropTag, out IntPtr ppProp);

[DllImport("MAPI32.DLL", CharSet=CharSet.Ansi, EntryPoint="MAPIFreeBuffer@4")]
public static extern void MAPIFreeBuffer(IntPtr lpBuffer);
Posted 27 Jan, 2005 05:07:24 Top
Bob Milani




Posts: 13
Joined: 2005-01-28
Sorry, I couldn't respond faster. I can't find the right call in MAPI32. Can you tell me which one it is?

Thanks,
Bob
Posted 28 Jan, 2005 02:53:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Bob.

The method HrGWResolveAddress is a wrapper around some functions in MAPI.
You should use the IAddrBook::PrepareRecipients and IABContainer::ResolveNames methods from MAPI. You can see more detailed information here

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchserv/html/adrssing_5oc3.asp
Posted 28 Jan, 2005 04:27:04 Top