none
Not getting contact items from outlook 2010 RRS feed

  • Question

  • I am developing a WPF-C# application and fetching MS Outlook 2010 contact items using Redemption. It is working fine if my Outlook has only one SMTP account. But if I configure another account which is exchange server account then I don't get any contact item from the same code. Following is my code:
    Interop.Redemption.RDOItems folderItems = null;
            Interop.Redemption.RDOFolder folderContacts = null;
            Interop.Redemption.RDOFolder folderSuggestedContacts = null;
            List<GMContactItem> allOutlookContacts = null;
            object itemObj = null;
            List<Interop.Redemption.RDOContactItem> contactItemsList = null;
    
            try
            {
    
                folderContacts = (RDOFolder)RDOSessionItem.GetDefaultFolder(Interop.Redemption.rdoDefaultFolders.olFolderContacts);
                contactItemsList = new List<RDOContactItem>();
                folderItems = folderContacts.Items;
                for (int i = 1; folderItems.Count >= i; i++)
                {
                    itemObj = folderItems[i];
                    if (itemObj is Interop.Redemption.RDOContactItem)
                        contactItemsList.Add(itemObj as RDOContactItem);
                    else
                        Marshal.ReleaseComObject(itemObj);
                }
    
                Marshal.ReleaseComObject(folderItems);
                folderItems = null;
    
    
                // getting items from the Suggested Contacts folder in Outlook 
                folderSuggestedContacts = RDOSessionItem.GetDefaultFolder(
                                          rdoDefaultFolders.olFolderSuggestedContacts);
                if (folderSuggestedContacts != null)
                {
                    folderItems = folderSuggestedContacts.Items;
                    for (int i = 1; folderItems.Count >= i; i++)
                    {
                        itemObj = folderItems[i];
                        if (itemObj is Interop.Redemption.RDOContactItem)
                            contactItemsList.Add(itemObj as Interop.Redemption.RDOContactItem);
                        else
                            Marshal.ReleaseComObject(itemObj);
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }

    When I delete my exchange server account then it work fine and if I add exchange server account in Outlook then this code has no exception but don't give any contact item. Can anybody suggest me that what could be the issue here. Thanks in advance.

    -Surya

    Wednesday, March 13, 2013 12:02 PM

Answers

  • If you need a default folder from a secondary store, calll RDOStore.GetDEfaultFolder instead of RDOSession.GetDefaultFolder (which returns folders from the default store).

    The stores can be accessed using the RDOSession.Stores collection.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, March 14, 2013 1:16 PM

All replies

  • Do you actually have any contacts in the default Contacts folder in the Exchange mailbox?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, March 13, 2013 3:38 PM
  • Hi Dmitry, basically I am working with two accounts one is SMPT and other is exchange server. Yes there are contacts in my exchange mailbox because when I open select name dialog, it contains many contacts. Apart from this, second account which is SMTP account, this has many contacts in address book as well. Also, if I run the same application with outlook 2007 then it is working good.
    Wednesday, March 13, 2013 6:55 PM
  • SMTP accounts do not have stores. Do you mean a PST store with some POP3/SMTP account delivering to it?

    When looking at the Select Names dialog, are you seeing Global Address Book entries or the contents of the Contact folder? What do you see if you select the Contact folder in the Exchange mailbox?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, March 14, 2013 6:37 AM
  • Hi Dmitry, If we talk about exchange server account, yes you are right, the contacts are in Global Address List and no contact is present in Contact list. But I have configured both SMTP and exchange server account at the same time. You are correct that exchange server account's Contact list doesn't contains address entries in it but SMTP account contains.

    Problem is it that when I call  RDOSessionItem.GetDefaultFolder(Interop.Redemption.rdoDefaultFolders.olFolderContacts);

    It gives me contact folder of exchange server account. I am not able to find the contact folder of SMTP account. I have tried changing the default account in Outlook but behavior is same. Can you please suggest me how can I find contact folder of SMTP account when. More general, how can we find contact folder of a specific account if more than one account are configured in outlook?

    Thursday, March 14, 2013 9:24 AM
  • If you need a default folder from a secondary store, calll RDOStore.GetDEfaultFolder instead of RDOSession.GetDefaultFolder (which returns folders from the default store).

    The stores can be accessed using the RDOSession.Stores collection.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, March 14, 2013 1:16 PM