Search code examples
outlookoffice365exchangewebservices

How to retrive 'X-PublicFolderMailbox' using soap ews


To route the requests to a public folder mailbox, you need to set the X-AnchorMailbox and X-PublicFolderMailbox headers to specific values returned by the Autodiscover service.

I have retrieved 'X-AnchorMailbox' value using the below soap call.

    <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover"
    xmlns:wsa="http://www.w3.org/2005/08/addressing"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <a:RequestedServerVersion>Exchange2010</a:RequestedServerVersion>
        <wsa:Action>http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettings</wsa:Action>
        <wsa:To>https://outlook.com/autodiscover/autodiscover.svc</wsa:To>
    </soap:Header>
    <soap:Body>
        <a:GetUserSettingsRequestMessage
            xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover">
            <a:Request>
                <a:Users>
                    <a:User>
                        <a:Mailbox>%s</a:Mailbox>
                    </a:User>
                </a:Users>
                <a:RequestedSettings>
                    <a:Setting>PublicFolderInformation</a:Setting>
                </a:RequestedSettings>
            </a:Request>
        </a:GetUserSettingsRequestMessage>
    </soap:Body>
</soap:Envelope>

But I am not able to fetch X-PublicFolderMailbox using soap call. Please help with xml schema and endpoint for request.


Solution

  • You don't use SOAP to get the X-PublicFolderMailbox value you need to make a POX (Plain old XML) auto-discover request against the Mailbox from the PublicFolderInformation eg

    <?xml version="1.0" encoding="utf-8"?>
    <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
      <Request>
        <EMailAddress>[email protected]</EMailAddress>
        <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
      </Request>
    </Autodiscover>

    and use the Server value from the response as per https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-route-public-folder-hierarchy-requests?redirectedfrom=MSDN