EWS API 2.0 Read Calendar information-read content considerations

Source: Internet
Author: User

[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.