在Exchange中获取日历项目

时间:2014-12-03 08:31:50

标签: c# list generics sharepoint exchangewebservices

我的Sharepoint 2 Exchange工具有点问题。也许某人可以帮助我:)

using (ClientContext clientContext = new ClientContext(m_Office365URL))
        {


            SecureString passWord = new SecureString();
            foreach (char c in m_password.ToCharArray()) passWord.AppendChar(c);
            SharePointOnlineCredentials xCred = new SharePointOnlineCredentials(m_userName, passWord);
            clientContext.Credentials = xCred;
            Web xWeb = clientContext.Web;
            clientContext.Load(xWeb);
            clientContext.Load(clientContext.Site.RootWeb);
            clientContext.ExecuteQuery();
            DateTime calDate = startDate;
            List targetList = xWeb.Lists.GetByTitle(m_TargetListName);
            clientContext.Load(targetList);
            clientContext.ExecuteQuery();

这完全是一个避风港里面的任何错误。 现在我的目的是尽可能地为Exchange工作。

这是我迄今为止所拥有的:

ExchangeService m_Service = new ExchangeService(m_Url);
            SecureString passWord = new SecureString();
            foreach (char c in m_Password.ToCharArray()) passWord.AppendChar(c);
            m_Service.Credentials = new WebCredentials(m_UserName, m_Password);

            foreach (Appointment appointment in m_Service.FindItems(WellKnownFolderName.Calendar, new ItemView(int.MaxValue)))
            { 
                DateTime calDate = startDate;

                ExchangeService xWeb = m_Service;                             
                m_Service.UpdateItems(xWeb);                             
                m_Service.Load(m_Service.Site.RootWeb);                             
                m_Service.ExecuteQuery();                             

                List targetList = xWeb.Lists.GetByTitle(m_TargetListName);                             
                m_Service.Load(targetList);                             
                m_Service.ExecuteQuery();

但是你可以猜到我会在#34; ExchangeService xWeb = new m_Service" 肯定m_Service.UpdateItems,m_Service.Load等也不会工作。

如果有人可能对我有暗示,那就太棒了。

1 个答案:

答案 0 :(得分:0)

我可以使用以下命令运行此代码:

            System.Net.ServicePointManager.ServerCertificateValidationCallback = Ise_ExchangeInterface.CertificateValidationCallBack;
            m_Service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            m_Service.Credentials = new WebCredentials(m_UserName, m_Password);
            m_Service.AutodiscoverUrl(m_UserName, Ise_ExchangeInterface.RedirectionUrlValidationCallback);