locked
find Public folder details using Exchange Web Services? RRS feed

  • Question

  • Hi..
    I want to get the Exchange Server Public Folder following deatils using Exchange Server web service. I dont want cmdlts.

    Display Name, Alias Name, Fully qualified domain name of object
    Home Server, Mailbox Store, E-mail, Public Folder Tree
    Path, Address List Name, Public Folder Description
    Folder Path, Client Permissions

    I am using VS2010 so I need C# sample for my task....


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"

    Wednesday, July 4, 2012 1:08 PM

Answers

  • When looking at error make sure you look at the Inner exception its hard to tell what's going wrong otherwise. Eg if its a authentication issue you should be getting a 401 type error.

    On 2010 you need to make sure you initialize the Cookie container else it wont process the Exchange cookie correctly eg

    ServiceBinding.CookieContainer = new CookieContainer();

    You might want to also test EWS using the EWSeditor http://ewseditor.codeplex.com/ this will ensure that you are using the correct URL, Config and Authentication and that EWS is working okay.

    Cheers
    Glen

    • Marked as answer by P Elayaraja Wednesday, July 25, 2012 6:53 AM
    Friday, July 6, 2012 9:23 AM

All replies

  • Some of those properties would only be valid if the Folder is mail enabled and not all folders are Mail-Enabled.  I would suggest you look at one of the Folders you want to work with using a Mapi Editor like OutlookSpy or MFCMapi. All the Mapi properties you can see in these editor you can access using EWS via Extended Properties http://msdn.microsoft.com/en-us/library/dd633691%28EXCHG.80%29.aspx . For MailEnabled public folders the extra information will be held on the Active Directory Proxy Object which you would need to use LDAP to access. You can get the GUID for the Ad Proxy from the PidTagPublicFolderProxy http://msdn.microsoft.com/en-us/library/ee178794%28v=exchg.80%29 property eg

                ExtendedPropertyDefinition PR_PF_PROXY = new ExtendedPropertyDefinition(0x671D, MapiPropertyType.Binary);
                PropertySet PsPropertySet = new PropertySet(PR_PF_PROXY);
                Folder meMailEnabledFolder = Folder.Bind(service, PublicFolder.Id, PsPropertySet);
                Object propVal = null;
                if(meMailEnabledFolder.TryGetProperty(PR_PF_PROXY,out propVal){
                    String pfProxy = BitConverter.ToString((Byte[])propVal);
                    DirectoryEntry deDirEnt = new DirectoryEntry(("LDAP://<GUID=" + pfProxy.Replace("-", "") + ">"));
                }
    Cheers
    Glen
    Thursday, July 5, 2012 6:04 AM
  • Hi Geln..
    Thanks for reply.. I want without EWS Managed API..
    So I have write the below code and I got the following error..
    I dont know why?

    Code Snipt:

    private Boolean ValidateCertificate(Object Sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return true;
            }
            private void MailboxSize_Load(object sender, EventArgs e)
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);
                GetPublicGeolder();
            }
            private void GetPublicGeolder()
            {
                 
                ExchangeServiceBinding serviceBinding = new ExchangeServiceBinding();            
                serviceBinding.RequestServerVersionValue = new RequestServerVersion();
                serviceBinding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010;                        
                serviceBinding.Url = "https://Rd49/EWS/Exchange.asmx";            
                serviceBinding.Credentials = new NetworkCredential("Admin", "XXXXXXXX", "YYYYYYY");
                serviceBinding.Proxy = new WebProxy();            
                FindFolderType request = new FindFolderType();
                request.FolderShape = new FolderResponseShapeType();
                request.FolderShape.BaseShape = DefaultShapeNamesType.AllProperties;                        
                DistinguishedFolderIdType publicFoldersRootId = new DistinguishedFolderIdType();
                publicFoldersRootId.Id = DistinguishedFolderIdNameType.publicfoldersroot;
                request.ParentFolderIds = new BaseFolderIdType[] { publicFoldersRootId };            
                request.Traversal = FolderQueryTraversalType.Shallow;
                FindFolderResponseType response = serviceBinding.FindFolder(request);   //<------Error here                     
                FindFolderResponseMessageType responseMessage = response.ResponseMessages.Items[0] as FindFolderResponseMessageType;                       
                if (responseMessage.ResponseClass == ResponseClassType.Success)
                {              
                    foreach (FolderType folder in responseMessage.RootFolder.Folders)
                    {
                        listBox1.Items.Add(folder.DisplayName);
                    }
                }
            }

    Error got from that mentioned line:

    So please Guide me....


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"

    Thursday, July 5, 2012 10:29 AM
  • When looking at error make sure you look at the Inner exception its hard to tell what's going wrong otherwise. Eg if its a authentication issue you should be getting a 401 type error.

    On 2010 you need to make sure you initialize the Cookie container else it wont process the Exchange cookie correctly eg

    ServiceBinding.CookieContainer = new CookieContainer();

    You might want to also test EWS using the EWSeditor http://ewseditor.codeplex.com/ this will ensure that you are using the correct URL, Config and Authentication and that EWS is working okay.

    Cheers
    Glen

    • Marked as answer by P Elayaraja Wednesday, July 25, 2012 6:53 AM
    Friday, July 6, 2012 9:23 AM