日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

EWS API 2.0读取日历信息-读取内容注意事项

發布時間:2025/4/14 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 EWS API 2.0读取日历信息-读取内容注意事项 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

采用模擬賬號的方式讀取日歷信息,注意下日歷的內容讀取(Body)讀取。代碼如下:(采用 EWS API 2.0版本)

1、讀取內容前必須設置如下屬性:否則會提示:You must load or assign this property before you can read its value? Body

如下圖:

//*************************以為設置為讀取內容,否則會提示:You must load or assign this property before you can read its value Body PropertySet detailedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.Recurrence); service.LoadPropertiesForItems(from Item item in findResults select item, detailedPropertySet); //******************************

設置后正常。

2、如果想讀取內容的純文本,目前Exchange server2010內的版本支持讀取帶HTML的內容。調用代碼如下:

//如果文本不為空 if (item.TextBody != null) { TextBody txtBody = item.TextBody; // info.BodyText = txtBody.Text; }

?

調用后出現如下錯誤:

所以只能用正則表達式獲取文本內容。

?

附帶正確代碼:

#region//讀入日歷信息 /// <summary> /// 讀入日歷信息 /// </summary> /// <param name="config">配置參數</param> /// <param name="searchdtStart">開始時間</param> /// <param name="searchdtEnd">結束時間</param> /// <returns>返回列表</returns> private static List<CalendarInfo> GetCalendarList(EwsConfig config,DateTime searchdtStart,DateTime searchdtEnd) { //返回值 List<CalendarInfo> CalendarInfoList = new List<CalendarInfo>(); try { //讀取未讀郵件 CalendarFolder calendarfolder = (CalendarFolder)Folder.Bind(service, WellKnownFolderName.Calendar); //如果不為空 if (calendarfolder != null) { //檢索開始時間和結束時間 CalendarView calendarView = new CalendarView(searchdtStart, searchdtEnd); //檢索數據 FindItemsResults<Appointment> findResults = calendarfolder.FindAppointments(calendarView); //*************************以為設置為讀取內容,否則會提示:You must load or assign this property before you can read its value Body PropertySet detailedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.Recurrence); service.LoadPropertiesForItems(from Item item in findResults select item, detailedPropertySet); //****************************** //返回 foreach (Appointment item in findResults.Items) { //實體類 CalendarInfo info = new CalendarInfo(); //主題 info.Identity = item.ICalUid; //來源 info.Source = "Exchange2010"; //主題 info.Subject = item.Subject; //地區 info.Location = item.Location; //開始時間 info.StartTime = item.Start.ToLocalTime(); //結束時間 info.EndTime = item.End.ToLocalTime(); //url info.Url = item.WebClientReadFormQueryString; //加入如下,表示讀取內容,否則會提示如下: //HTML如果不為空 if (item.Body != null) { //html格式的內容 MessageBody body = item.Body; //讀取文本 info.BodyHtml = body.Text; } // //讀取id if (item.Id != null) { info.ItemIdType = new CalendarInfo.CalendarItemIdType { Id = item.Id.UniqueId, ChangeKey = item.Id.ChangeKey }; } //加入到集合中去 CalendarInfoList.Add(info); } } } catch (Microsoft.Exchange.WebServices.Data.ServiceResponseException ex) { throw ex; } //return return CalendarInfoList; } #endregion

轉載于:https://www.cnblogs.com/love007/p/3156852.html

總結

以上是生活随笔為你收集整理的EWS API 2.0读取日历信息-读取内容注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。