More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 18-Dec-2018 14:15

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 2 3 4 Next >> ]  
 Outlook and .NET Printer Friendly Version
Writing code with C# and VB.NET to create Outlook add-ins and other projects
Enumerating Contact Lists and Dist. Lists using Redemption
My client needs an application written in .Net to fetch all the contacts from given Dist. lists and contact lists created under each mailbox. I've been trying to do this in C# using Redemption but couldn't find the exact methods to pass the name of Contact List and get the contacts (First Name, Last Name etc).
Does anyone has an example or send me direction on how to use Redemption to get the contacts?
Thanks a lot for your help.

  28-Jun-2006  09:26
  28-Jun-2006  09:31   
Have you looked at these page:
  28-Jun-2006  09:38   
Yes, I did. All these examples are in VB and I tried to convert the AddressBook one to C# but didn't work. I can see all the AddressLists within my account but don't know how to pass the name of one Address List and get the contacts out of it. May be I'm missing few steps. I'm new to this. Please help. I might be way off. Here is my test code:
        static void Main(string[] args)
            Microsoft.Office.Interop.Outlook.Application app = null;
            Microsoft.Office.Interop.Outlook._NameSpace ns = null;
                app = new Microsoft.Office.Interop.Outlook.Application();
                ns = app.GetNamespace("MAPI");
                Redemption.RDOSessionClass rdoSession = new Redemption.RDOSessionClass();
                rdoSession.MAPIOBJECT = ns.MAPIOBJECT;
                int p = rdoSession.AddressBook.AddressLists("Test").Count;
                for(int i = 1;i < p;i++)
                string s = "";
            catch (System.Runtime.InteropServices.COMException ex)
                ns = null;
                app = null;
  28-Jun-2006  11:36   
AddressLists? You didn't ask about address lists. You asked about the contacts folders in each mailbox. Those are not the same thing at all. The first link I posted shows how to use the RDO Session.GetDefaultFolder method to return any default folder and iterate its items. You'd want to use olFolderContacts, not olFolderInbox. RDO should automatically return an RDOContactItem or RDODistListItem as appropriate.
  28-Jun-2006  11:38   
I got to the point where I can enumerate all the members within a dist. list under GAL and display their names. How do I get other properties like Phone, Address etc. ContactItem method does have all these properties. How can I associate GAL member with ContactItem to get all the properties?

  28-Jun-2006  12:02   
GAL members and ContactItems are two entirely different things, totally unrelated. For GAL members, you have to use MAPI property tags to return the fields you're interested in. See for a pre-RDO Redemption sample.
  28-Jun-2006  12:51   
That example is using the current mail item as reference to get to the Address Entry. I have the AddressEntry from GAL as RDOAddressEntry.
Sorry, my lack of knowledge for this object model is slowing me down. Here is the code I used to get members out of DL. I can only read the Name:
                app = new Microsoft.Office.Interop.Outlook.Application();
                ns = app.GetNamespace("MAPI");
                Redemption.RDOSessionClass rdoSession = new Redemption.RDOSessionClass();
                rdoSession.MAPIOBJECT = ns.MAPIOBJECT;
                Redemption.RDOAddressBook rdoAdd = rdoSession.AddressBook;
                Redemption.RDOFolder rdoFld= rdoSession.GetDefaultFolder(10);
                int p = 0;
                p = rdoFld.Items.Count;

                foreach(Redemption.RDOContactItem rdoItem in rdoFld.Items)
                //p = rdoAdd.AddressLists(false).Item("Detroit-Staff").AddressEntries.Count;
                p = rdoAdd.GAL.AddressEntries.Count;
                foreach(Redemption.RDOAddressEntry rdoEnt in rdoAdd.GAL.AddressEntries)
                    if(rdoEnt.Name.ToString() == "Staff")
                        int m = rdoEnt.Members.Count;
                        if(m > 0)
                            for(int x=0;x<m;x++)
  28-Jun-2006  13:16   
It doesn't matter how you get the AddressEntry. You still have to use its Fields collection to get at the properties beyond the basic name and address.
  28-Jun-2006  13:57   
Sue, I apprecieate all you help and I would be really reeeeeeeeeeally greatful to you if you could please send me an example on how to get the Fields collection based on my code above. I'm really stuck here and need to get this working today.

Thanks a lot.
  28-Jun-2006  14:46   
Is there any other way to get the Contacts out of spacific Contact List and Dist. List using Redemption or other method? I'm not restricted to C# only.
Does your book have any examples related to this problem?
I really need to resolve this problem.
  28-Jun-2006  15:26   
sorry, but I don't know C#. The code sample I've referred you to shows how easy it is, though:


'code to get the address entry --

Are we back to contacts now and not GAL entries? Your posts have been very confusing as they've gone back and forth between the two.
    Page [ 1 2 3 4 Next >> ]