none
Get a list of mailbox names using Exchange Web Service (EWS) with C# RRS feed

  • Question

    • Hi,

      My Outlook Client profile 2010 has access to 8 mailboxes. I need to get a list of mailbox names based on user outlook client profile, without hard-coding mailbox names using Exchange Web Service (EWS) API and C#. 

      Currently in VB6.0, I am using Redemption library to connect Outlook Client profile and read all mailboxes and it's folders/emails. I would like to migrate the VB6.0 application to C# using EWS API with the same approach. This application has to work generic on each and every business user machine.

      Please let me know if any way to get a list of mailboxes?

      Regards,

      Raghuveer <g class="gr_ gr_14 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="14" id="14">Pothadi</g>

    Monday, June 20, 2016 4:10 PM

All replies

  • You need to enumerate that from the Client Outlook profile if you have Redemption I would suggest you try the Profman library. You can also use the raw registry key (however they are different for every version of Outlook). If you using Outlook 2010 something like the following should work (on 2013 the root key needs to be Software\Microsoft\Office\15.0\Outlook\Profiles

                    String Root = (@"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles");
                    RegistryKey Profileskeys = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Root, true);
                    foreach (String SubKey in Profileskeys.GetSubKeyNames())
                    {
                        Console.WriteLine("Profile Name : " + SubKey);
                        String ChildKey = Root + "\\" + SubKey;
                        RegistryKey ChildProfKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(ChildKey, true);
                        foreach (String key in ChildProfKey.GetSubKeyNames())
                        {
                            RegistryKey ProfConfigKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey((ChildKey + "\\" + key),true);
                            var RegKeyValue = ProfConfigKey.GetValue("00036600");
                            if (RegKeyValue != null)
                            {
                                var SMTPKeyValue = ProfConfigKey.GetValue("001f6641");
                                if(SMTPKeyValue != null)
                                {
                                    Console.WriteLine(UnicodeEncoding.Unicode.GetString((byte[])SMTPKeyValue));
                                }
                            }
                        }
                    }

    What you need to connect to a Mailbox with EWS is the primarySMTP address which should be in the 001f6641 Key

    Cheers
    Glen

    Tuesday, June 21, 2016 3:17 AM
  • This really helped me to extract the list of mailboxes.

    Thank you for the information.

    Tuesday, June 21, 2016 2:20 PM