[From] http://www.cnblogs.com/love007/archive/2013/06/26/3156852.html
Use the demo account to read the calendar information, note the contents of the calendar reading (Body) read. The code is as follows: (with EWS API version 2.0)
1. The following properties must be set before reading the content: Otherwise you will be prompted: must load or assign this property before you can read its value Body
As follows:
Thought to be set to read content, otherwise you will be prompted: You must load or assign the property before you can read its value Body
New PropertySet (Basepropertyset.firstclassproperties, appointmentschema.recurrence);
in Findresults Select item, Detailedpropertyset);
//******************************
After setting up normal.
2. If you want to read plain text of the content, the current version within Exchange server2010 supports reading content with HTML. The calling code is as follows:
If the text is not empty
if (item. TextBody = null)
{
TextBody txtbody = Item. TextBody;
//
Info. BodyText = Txtbody.text;
}
The following error occurred after the call:
therefore, only regular expressions can be used to get the text content.
The correct code is included:
#region//read in Calendar information /// <summary> ///read in Calendar information/// </summary> /// <param name= "config" >Configuration Parameters</param> /// <param name= "Searchdtstart" >Start Time</param> /// <param name= "Searchdtend" >End Time</param> /// <returns>Return to list</returns> Private StaticList<calendarinfo>getcalendarlist (ewsconfig config,datetime searchdtstart,datetime searchdtend) {//return valueList<calendarinfo> calendarinfolist =NewList<calendarinfo>(); Try { //Read unread messagesCalendarFolder CalendarFolder =(CalendarFolder) folder.bind (service, Wellknownfoldername.calendar); //if it is not empty if(CalendarFolder! =NULL) { //retrieving start time and end timeCalendarView CalendarView =NewCalendarView (Searchdtstart, searchdtend); //Retrieving DataFinditemsresults<appointment> Findresults =CalendarFolder. Findappointments (CalendarView); //************************* thought to be set to read content, otherwise it would prompt: You must load or assign the property before you can read its value bodyPropertySet Detailedpropertyset =NewPropertySet (basepropertyset.firstclassproperties, appointmentschema.recurrence); Service. Loadpropertiesforitems ( fromItem IteminchFindresultsSelectitem, Detailedpropertyset); //****************************** //return foreach(Appointment iteminchfindresults.items) {//entity classCalendarinfo info =NewCalendarinfo (); //ThemeInfo. Identity =item. Icaluid; //SourceInfo. Source ="Exchange2010"; //ThemeInfo. Subject =item. Subject; //AreaInfo. Location =item. Location; //Start TimeInfo. StartTime =item. Start.tolocaltime (); //End TimeInfo. EndTime =item. End.tolocaltime (); //URLInfo. URL =item. webclientreadformquerystring; //Add the following to indicate the read content, otherwise you will be prompted as follows://HTML if not empty if(item. Body! =NULL) { //HTML-formatted contentMessageBody BODY =item. Body; //reading textInfo. bodyhtml =body. Text; } // //Read ID if(item. Id! =NULL) {info. Itemidtype=NewCalendarinfo.calendaritemidtype {Id = Item. Id.uniqueid, ChangeKey =item. Id.changekey}; } //add to the collection.Calendarinfolist.add (info); } } } Catch(Microsoft.Exchange.WebServices.Data.ServiceResponseException ex) {Throwex; } //return returncalendarinfolist; } #endregion