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读取日历信息-读取内容注意事项相关推荐
- java ews appointment_EWS API 2.0读取日历信息-读取内容注意事项
[from] http://www.cnblogs.com/love007/archive/2013/06/26/3156852.html 采用模拟账号的方式读取日历信息,注意下日历的内容读取(Bod ...
- 服务器读取内存信息,读取服务器内存信息工具
读取服务器内存信息工具 内容精选 换一换 Ascend-DMI工具主要为Atlas产品的标卡.板卡及模组类产品提供带宽测试.算力测试.功耗测试等功能.工具的功能介绍如表1所示.本系统通过调用底层DCM ...
- android通过USB读取身份证信息
一.USB的通信流程 搜索设备->建立连接->通信 , 全部代码请 "戳这" 1.搜索设备 /*** 获取目标UsbDevice* @param view*/publi ...
- 一段从API读取基金净值信息并写入Excel表的Python代码
有几天没发帖子了,主要是自己并非专业开发者,也不是IT从业者,撸代码和创意并不是那么多.今天贴一个前阵子折腾的抓取基金净值信息的Python代码吧,感谢小熊同学提供的API # -*- coding: ...
- alexa api php,php 读取 alexa信息
php 读取 alexa信息 function Alexa($domain) { $alexa = ''; $content = get_content('http://www.alexa.com/d ...
- JPEG图片扩展信息读取与改动
近日项目中须要用到往jpg图片中写入信息(非水印),经调研发现Android中已经封装了读写jpg图片扩展信息的api(ExifInterface). 相应api地址:http://developer ...
- 身份证读取设备开发解决方案:2、Android下通过usb转串口读取身份证信息
身份证读取设备开发解决方案:2.Android下通过usb转串口读取身份证信息 文章目录 身份证读取设备开发解决方案:2.Android下通过usb转串口读取身份证信息 1. 前言 2. 准备 3. ...
- web读取身份证信息(java语言)
其实实现读取身份证信息,代码其实没有多难,关键需要和硬件的厂商协调好,看他们的硬件是否支持二次开发(一般都支持).如果支持我们需要和他们拿到他们底层的jar包和api(接口文档),要是有demo就更好 ...
- 华视电子web读取身份证信息
首先的是加入要引用的dll文件,放到需要使用的电脑的位置,我的是 E:/soft/labor/Termb.dll 然后看congtroller层的代码是: import com.exa.dem.ent ...
最新文章
- 携手中国电信、中国联通,华为正式发布首个5G超级刀片站 A+P 2.0天线商用网络
- 开发函数计算的正确姿势 —— 使用 Fun Local 本地运行与调试
- 产品设计眼中的运营,互联网营销
- Linux无法打开sda硬盘,linux – 无法挂载’/ dev / sda’
- 深入理解事件循环机制
- 致歉!抖音Semi Design承认参考阿里Ant Design
- chrome全屏隐藏状态栏_PS技巧丨18个让你相见恨晚的PS隐藏技巧!
- c++求n的几次方_数理统计|笔记整理(E)——Ch7-C习题课
- Centos7 minmal 安装
- Python Flask教程
- CF280C Game on tree(期望dp)
- python 优点_python语言有什么优势
- 开发微信H5视频秀项目遇到的坑
- C(每日一题)——数据结构——创建一个线性链表(详细过程)
- qpython3 l_qpython3安装requirements_Python3安装配置【转】
- c语言的字符型都有什么作用是什么,字符型数据是什么意思怎么理解
- docker部署tf-serving模型
- 口碑最好的国产蓝牙耳机,2021国产最好用的蓝牙耳机
- 使用苹果的地图与定位
- 父类(指针、引用)指向子类对象