migarating calendatar data from shared exchange 2010 calendar to sharepoint 2013
2013-05-24 08:48
489 查看
public static void AddAppointmentToSharepointWithClientObjectModule(DateTime s,DateTime e,string title,string desc) { string siteUrl = "https://intern.abc.net.cn/"; ClientContext clientContext = new ClientContext(siteUrl); NetworkCredential Cred = new NetworkCredential("test", "abcdefg", "domain"); clientContext.Credentials = Cred; //end authentication Microsoft.SharePoint.Client.List oList = clientContext.Web.Lists.GetByTitle("cal"); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem oListItem = oList.AddItem(itemCreateInfo); oListItem["Title"] = title; oListItem["Description"] = "New Event created using SharePoint Object Model"; //oListItem["Location"] = "First Floor"; oListItem["EventDate"] = s; oListItem["EndDate"] = e; //oListItem["Category"] = "Business"; //oListItem["fAllDayEvent"] = false; oListItem.Update(); clientContext.ExecuteQuery(); } public static void GetExchangePublicCalendar() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); ExData.ExchangeService service = new ExData.ExchangeService(ExData.ExchangeVersion.Exchange2010_SP2); service.Credentials = new NetworkCredential("test", "abcdefg", "domain"); service.Url = new Uri("https://mail.abc.local/ews/Exchange.asmx"); //service.Credentials = new NetworkCredential("test", "abcdefg", "temp"); //service.Url = new Uri("https://cas.temp.local/ews/Exchange.asmx"); var rootfolder = ExData.Folder.Bind(service, ExData.WellKnownFolderName.PublicFoldersRoot); rootfolder.Load(); foreach (ExData.Folder folder in rootfolder.FindFolders(new ExData.FolderView(int.MaxValue))) { if (!string.IsNullOrEmpty(folder.DisplayName)) { Console.WriteLine(folder.DisplayName); try { foreach (ExData.Folder f1 in folder.FindFolders(new ExData.FolderView(int.MaxValue))) { if (f1.DisplayName.ToLower() == "calender") { Console.WriteLine(" ---------"); sb.AppendLine(" ---------"); var _cal = f1.Id; var _calendarView = new Microsoft.Exchange.WebServices.Data.CalendarView(System.DateTime.Now.AddYears(-6).AddYears(-1), System.DateTime.Now.Date.AddYears(-6).AddYears(1)); foreach (Microsoft.Exchange.WebServices.Data.Appointment appointmentItem in service.FindAppointments(_cal, _calendarView)) { AddAppointmentToSharepointWithClientObjectModule(appointmentItem.Start, appointmentItem.End,appointmentItem.Subject,""); Console.WriteLine(appointmentItem.Subject); sb.AppendLine(appointmentItem.Subject); Console.WriteLine(appointmentItem.Start); sb.AppendLine(appointmentItem.Start.ToString()); Console.WriteLine(appointmentItem.End); sb.AppendLine(appointmentItem.End.ToString()); //appointmentItem.Load(); //Console.WriteLine(appointmentItem.Body); } Console.WriteLine(" ---------"); sb.AppendLine(" ---------"); } Console.WriteLine(" ++" + f1.DisplayName); foreach (ExData.Folder f2 in f1.FindFolders(new ExData.FolderView(int.MaxValue))) { Console.WriteLine(" ++" + f2.DisplayName); sb.AppendLine(" ++" + f2.DisplayName); } } } catch (Exception ex) { Console.WriteLine(" --" + ex.Message); sb.AppendLine(" --" + ex.Message); } } } log(sb.ToString()); } static void log(string str) { System.IO.File.AppendAllText(@"c:\log.txt",str); }
相关文章推荐
- Custom Ribbon in SharePoint 2010 & which not wrok when migrate from 2010 to 2013
- Migrate the Metadata from sharepoint 2010 to sharepoint 2013
- How to Deploy Solution (WSP) from SharePoint 2010 Central Administration
- Step By Step Guide to configure the “Replicating directory changes” for SharePoint 2010 and 2013
- Creating a SharePoint BCS .NET Connectivity Assembly to Crawl RSS Data in Visual Studio 2010
- Using SharePoint 2003 Web Services to Retrieve Data From A List
- How to open MS word document from the SharePoint 2010 using Microsoft.Office.Interop.dll
- upgrade sharepoint 2007 to 2010,2010 to 2013
- In-Place upgrade to Team Foundation Server (TFS) 2015 from TFS 2013Team Foundation Server TFS TFS 2015 TFS upgrade TFS with Sharepoint
- How to Integrate SAP Business Data Into SharePoint 2010 Using Business Connectivity Services and LINQ to SAP
- Plan for apps for SharePoint 2013(You need to ensure that users can install apps from the App Catal)
- Upgrade from SharePoint 2010 to SharePoint 2016
- [msdn]Submitting Data from InfoPath 2007 to a SharePoint List
- Intro to eDiscovery in SharePoint, Exchange, and Lync 2013
- Submitting data to a SharePoint 2010 List using InfoPath - CAML
- Step by step configuration of Outgoing Emails from SharePoint to Microsoft Online
- Shareoint 2013 APP Store添加APP时报错“Everything is fine, but we had a small problem getting your license. Please go back to the SharePoint Store to get t”
- Visual guide to Windows Live ID authentication with SharePoint 2010 - part 1
- [转]How to Integrate SharePoint 2010 with Reporting Services
- 【转】Import User Profile Photos from Active Directory into SharePoint 2010