Access WAB or MS Outlook Address book via C#
Hi!
I am trying to access WAB or MS Outlook Address book via C# in VS 2005 under Vista.
Any idea? I have tried to find out from web but look like there are a lot of way to do it and different MS Outlook version (Ms Office 2003or XP or 2007) have diff way to code.
Alex
Answers
The Global Address List (GAL) is an address book derived from Active Directory data maintained by the network administrator on the server.
If you want to access a user's Outlook contacts, use the Namespace.GetDefaultFolder method to return the contacts folder as a MAPIFolder or (in Outlook 2007) Folder object, then iterate that folder's Items or use the Items.Find or Items.Restrict method to filter for specific criteria.
All Replies
What exactly are you seeking to do with the Outlook Address Book? It's accessible through a couple of different techniques in the OUtlook object model, but the details depend on what version of Outlook your add-in is written for.
WAB would be beyond the scope of this forum.
Are you trying to get information from the users address book or the global address book? If the global address book, I would use LDAP and read it that way.
i am trying to retrieve contact from outlook 2007.
might explaint diff user and global address book? how to retrieve contact from them?
The Global Address List (GAL) is an address book derived from Active Directory data maintained by the network administrator on the server.
If you want to access a user's Outlook contacts, use the Namespace.GetDefaultFolder method to return the contacts folder as a MAPIFolder or (in Outlook 2007) Folder object, then iterate that folder's Items or use the Items.Find or Items.Restrict method to filter for specific criteria.
Thanks. I am able to get contact folder called "contact". But inside WAB, there are more than one contact folders,e.g. created by company which is list of employees contact list catogarise by country.
How to access these?
Alex
- <P align=left><FONT face=Arial>It sounds like you're still confused about what address book you're looking at. Outlook does not use the WIndows Address Book. That is a feature of Outlook Express and Windows Mail. </FONT></P>
<P align=left> </P>
<P align=left>Central company address lists would be part of the Global Address List. You can access those lists through the Namespace.AddressLists collection or access the data, which is stored in Active Directory, directly through LDAP as Steve already pointed out. </P> Great to hear from you again. I can see you all over in Outlook forums.
Back on track.
I managed to get GAL and now i need to get particular GAL folder item detail e.g. FullName, email, tel and etc just like contactitem.
objOutlook =
new Outlook.Application();objNS = objOutlook.GetNamespace(
"MAPI");Outlook.
AddressLists objAddressList = objNS.AddressLists;
// Redemption.AddressLists rals = (Redemption.AddressLists) for (int i = 1; i < (objAddressList.Count + 1); i++) { string stest = objAddressList.Item(i).Name; }using below line will only get the name. how to get more than that e.g. email, tel, fax without using CDO?
string
sname1 = objAddressList.Item(20).c.Item(1).Name;I'm using Vista business, VS2005 and Outlook 2007.
Use the new PropertyAccessor object and its GetProperty and GetProperties methods to get to information other than that exposed in the properties of the AddresssEntry object; see http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._propertyaccessor_members.aspx.
FYI, If you have VS set to use online help, you can now get to details about all Outlook objects just by putting the cursor on an Outlook type and pressing F1; see http://blogs.msdn.com/rgregg/archive/2007/07/26/outlook-2007-pia-documentation-online.aspx.
HI! Sue Mosher,
I'm sorry need your help again to give an example how to use GetProperty or GetProperties for GAL?
Alex
To hopefully help with the original question, I've been working on a C# library for accessing WAB contacts in Vista, available at www.codeplex.com/Contacts. I realize it's outside the scope of this forum, but I stumbled across this post and thought I'd mention it.
sorry, recently stuck with other project. I'm going to look on it next week. Thanks 1st.
Hi Sue Mosher,
I want to fetch Global Address List(GAL) contacts in to my ASP.NET application, i am using Exchange Server 2003, outlook 2003, .NET Framework 1.2, using MAPI i was able to fetch only Name and Address value of the contacts in GAL, PropertyAccessor object is not available to me as i am using Microsoft Outllok 11.0 object library so is there any other method to achieve this, i mean in outlook 2003 using MAPI is there any other method to retrive all the properties of contacts in GAL. Thanks.
Hi
I have exactly the same problem with only a diference iam using c#, did you solve it? if yes , can you tell me please how?
best regards,
Mauro Batista
- Mauro, given that at least three different scenarios have been discussed in this thread, you need to define exactly what "the same problem" means for you, including the version(s) of Outlook you are supporting. Also explain which of the posted solutions you've already tried, giving relevant code snippets. You might want to start a new thread on this issue, as this one is rather stale.
Hi Sue
Sorry i will create a new thread with my problem
best regards
Mauro Batista
Hi
I am trying to access the gal address book in outlook 2003 and retrive the telephone number. I am only only a beinger at C# does any one have the code
Regards
John


