Как читать общую папку Exchange 2010 SP 1 с помощью c # - PullRequest
2 голосов
/ 05 июля 2011

Я пытаюсь прочитать общую папку, размещенную в ExchangeServer 2010 SP1.Я могу подключиться, но когда я пытаюсь прочитать папку, я получаю сообщение об ошибке.Надеюсь, кто-нибудь сможет поделиться своим опытом.Ниже приведен код, который я выполняю, и после этого я получаю сообщение об ошибке SoapException Unhandled.

ExchangeServiceBinding serviceBinding = new ExchangeServiceBinding();
    serviceBinding.Credentials = new NetworkCredential("XXXXXXXX", "YYYYYY", "zzzzzzzz");
    serviceBinding.RequestServerVersionValue = new RequestServerVersion();
    serviceBinding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010_SP1;
    serviceBinding.Url = @"https://the.domain.of.my.work/EWS/exchange.asmx";

    DistinguishedFolderIdType publicFolderRoot = new DistinguishedFolderIdType();
    publicFolderRoot.Id = DistinguishedFolderIdNameType.publicfoldersroot;
    FindFolder(serviceBinding, publicFolderRoot, @"All Public Folders");

private static FolderIdType FindFolder(ExchangeServiceBinding esb, BaseFolderIdType folderId, string folderName)
        {

            //FindPublicFolderType request = new FindPublicFolderType();
            FindFolderType request = new FindFolderType();
            request.Traversal = FolderQueryTraversalType.Shallow;
            request.FolderShape = new FolderResponseShapeType();
            request.FolderShape.BaseShape = DefaultShapeNamesType.AllProperties;
            request.ParentFolderIds = new BaseFolderIdType[] { folderId };

            //Giving error at this below 
             FindFolderResponseType response = esb.FindFolder(request);

            foreach (ResponseMessageType rmt in response.ResponseMessages.Items)
            {
                if (rmt.ResponseClass == ResponseClassType.Success)
                {
                    FindFolderResponseMessageType ffResponse = (FindFolderResponseMessageType)rmt;

                    if (ffResponse.RootFolder.TotalItemsInView > 0)
                    {
                        foreach (BaseFolderType subFolder in ffResponse.RootFolder.Folders)
                            if (subFolder.DisplayName == folderName)
                                return subFolder.FolderId;
                        return null;
                    }
                    Console.WriteLine("Can't find '" + folderName + "'.");
                }

                else
                {

                    //Console.WriteLine("Response was: " + rmt.ResponseClass + Environment.NewLine + rmt.MessageText);
                    MessageBox.Show("Response was: " + rmt.ResponseClass + Environment.NewLine + rmt.MessageText);

                }

            }

            return null;

        }

После выполнения кода выше я сталкиваюсь с ошибкой, упомянутой ниже

System.Web.Services.Protocols.SoapException
System.Web.Services.Protocols.SoapException
was unhandled   Message="The mailbox
that was requested doesn't support the
specified RequestServerVersion."  
Source="System.Web.Services"  
Actor=""   Lang="en-US"   Node=""  
Role=""   StackTrace:
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream
responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
       at RnDExchangePublicFolder.ExchangeWebServices.ExchangeServiceBinding.FindFolder(FindFolderType
FindFolder1) in
E:\Data\VS2008\RnDExchangePublicFolder\RnDExchangePublicFolder\Web
References\ExchangeWebServices\Reference.cs:line
547
       at RnDExchangePublicFolder.Form1.FindFolder(ExchangeServiceBinding
esb, BaseFolderIdType folderId, String
folderName) in
E:\Data\VS2008\RnDExchangePublicFolder\RnDExchangePublicFolder\Form1.cs:line
51
       at RnDExchangePublicFolder.Form1.btnConnect_Click(Object
sender, EventArgs e) in
E:\Data\VS2008\RnDExchangePublicFolder\RnDExchangePublicFolder\Form1.cs:line
39
       at System.Windows.Forms.Control.OnClick(EventArgs
e)
       at System.Windows.Forms.Button.OnClick(EventArgs
e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs
mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message&
m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message&
m)
       at System.Windows.Forms.ButtonBase.WndProc(Message&
m)
       at System.Windows.Forms.Button.WndProc(Message&
m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr
lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32
pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form
mainForm)
       at RnDExchangePublicFolder.Program.Main()
in
E:\Data\VS2008\RnDExchangePublicFolder\RnDExchangePublicFolder\Program.cs:line
18
       at System.AppDomain._nExecuteAssembly(Assembly
assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String
assemblyFile, Evidence
assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
       at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback
callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Может кто-нибудь поделиться своим опытом, что вызывает проблему или продолжить .?

Спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...