exchange EWS 开发随笔二
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Net;
6
7
8 namespace ExchangeEWS
9 {
10 class Program
11 {
12 static void Main(string[] args)
13 {
14 ExchangeServiceBinding esb = new ExchangeServiceBinding();
15
16 esb.Credentials = new NetworkCredential("MailAdmin", "App1234", "xxx.com");
17 esb.RequestServerVersionValue = new RequestServerVersion() { Version = ExchangeVersionType.Exchange2007_SP1 };
18 esb.ExchangeImpersonation = new ExchangeImpersonationType();
19
20 esb.ExchangeImpersonation.ConnectingSID = new ConnectingSIDType()
21 {
22 PrimarySmtpAddress = "liujunxun@lab.com"
23
24 }; ;
25
26 esb.Url = @"http://mail.lab.com/EWS/Exchange.asmx";
27
28 string id = GetRecurringMasterFromOccurrenceId(esb, new ItemIdType()
29 {
30 ChangeKey = "DwAAABYAAACmByZGocQSToqby5KUV81FAqM8fV5y",
31 Id = "AAMkADdlNTVhMTlmLWYxNWQtNDNlZi1hMTIyLTNkZTRkN2VkN2ZlNgFRAAiIy+JqlstAAEYAAAAAixAkoQ62ZEGeBtVLJhjjZwcApgcmRqHEEk6Km8uSlFfNRQFpAZtwWgAApgcmRqHEEk6Km8uSlFfNRQKjPH0b6AAAEA=="
32 }).Id;
33
34
35
36 }
37
38 /// <summary>
39 /// Deletes an attachment and returned the Id and updated change key of the
40 /// parent item
41 /// </summary>
42 /// <param name="binding">Exchange binding to use</param>
43 /// <param name="attachmentId">Attachment id to delete</param>
44 /// <returns>Id and updated change key of the parent item</returns>
45 ///
46 public static ItemIdType DeleteAttachmentAndGetItem(
47 ExchangeServiceBinding binding,
48 RequestAttachmentIdType attachmentId)
49 {
50 DeleteAttachmentType request = new DeleteAttachmentType();
51 request.AttachmentIds = new RequestAttachmentIdType[] { attachmentId };
52 DeleteAttachmentResponseType response =
53 binding.DeleteAttachment(request);
54 DeleteAttachmentResponseMessageType responseMessage =
55 response.ResponseMessages.Items[0] as
56 DeleteAttachmentResponseMessageType;
57 if (responseMessage.ResponseCode != ResponseCodeType.NoError)
58 {
59 throw new Exception("Delete attachment failed. Response code: " +
60 responseMessage.ResponseCode.ToString());
61 }
62 else
63 {
64 // Normally, we could just return the root item id from our Delete
65 // Attachment response. But I want to prove a point here, so we will
66 // call GetItem and see what happens.
67
68 // There is a bug here.
69 //
70 GetItemType getRequest = new GetItemType();
71 getRequest.ItemIds = new BaseItemIdType[] {
72 responseMessage.RootItemId };
73 getRequest.ItemShape = new ItemResponseShapeType(
74 ) { BaseShape = DefaultShapeNamesType.IdOnly };
75 GetItemResponseType getResponse = binding.GetItem(getRequest);
76 ItemInfoResponseMessageType getResponseMessage =
77 getResponse.ResponseMessages.Items[0] as
78 ItemInfoResponseMessageType;
79
80 if (getResponseMessage.ResponseCode != ResponseCodeType.NoError)
81 {
82 throw new Exception("GetItem failed. Response code: " +
83 getResponseMessage.ResponseCode.ToString());
84 }
85 else
86 {
87 return getResponseMessage.Items.Items[0].ItemId;
88 }
89 }
90 }
91
92
93
94 public static ItemIdType GetRecurringMasterFromOccurrenceId(
95 ExchangeServiceBinding binding,
96 ItemIdType idOfOccurrence)
97 {
98 // Create the RecurringMasterItemIdType instance that we will pass to GetItem.
99 //
100 RecurringMasterItemIdType recurringMasterId =
101 new RecurringMasterItemIdType();
102 recurringMasterId.OccurrenceId = idOfOccurrence.Id;
103 recurringMasterId.ChangeKey = idOfOccurrence.ChangeKey;
104
105 GetItemType getItemRequest = new GetItemType();
106 getItemRequest.ItemShape = new ItemResponseShapeType();
107 getItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.IdOnly;
108
109 getItemRequest.ItemIds = new RecurringMasterItemIdType[] {
110 recurringMasterId };
111
112 // Make the call to the GetItem web method, check for success
113 // and return the item id accordingly
114 //
115 GetItemResponseType response = binding.GetItem(getItemRequest);
116 ItemInfoResponseMessageType responseMessage =
117 response.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
118
119 if (responseMessage.ResponseCode != ResponseCodeType.NoError)
120 {
121 throw new Exception("GetItem failed with response code " +
122 responseMessage.ResponseCode.ToString());
123 }
124
125 return responseMessage.Items.Items[0].ItemId;
126 }
127
128
129 }
130 }
131
转载于:https://www.cnblogs.com/clock2008/archive/2009/08/04/1538595.html
exchange EWS 开发随笔二相关推荐
- 如何提高码农产量,基于ASP.NET MVC的敏捷开发框架之移动端开发随笔二
前言 在前一篇文章中我已经做过开篇,接下来的随笔会详细讲一下我们的开发框架是如何实现的,专业的事由专业的人来讲,以后就由我们的高级码农小李英文名查尔斯和他的师父厂长(因为姓陈,酷爱摄影,我们的文艺片都 ...
- 3D数学基础:图形与游戏开发---随笔二
笛卡尔坐标系统 笛卡尔不仅创立了解析集合,将当时完全分离的代数学和几何学联系到一起,还在回答"怎样判断某件事物是真的?"这个哲学问题上迈出了一大步,使后来的一代代哲学家能够轻松起来 ...
- 软件开发随笔系列二——关于架构和模型
软件开发随笔系列二--关于架构和模型 文章目录 软件开发随笔系列二--关于架构和模型 软件模型 功能模型 概念层 边界 参与方 分组分类 逻辑层 功能组织图 层次.模块化 接口 流程模型 概念层 业务 ...
- 软件开发随笔系列一——分布式架构实现
软件开发随笔系列一--分布式架构实现 文章目录 软件开发随笔系列一--分布式架构实现 理论基础 分布式架构的实现 内核框架 应用开发 基础设施 服务接入 监控 日志监控 调用链监控 度量指标监控 健康 ...
- IOS 逆向开发(二)密码学 HASH
IOS 逆向开发(二)密码学 HASH 1. HASH算法简介 1.1 HASH是什么? 1.2 Hash的特点 1.3 Hash的作用 1.4 Hash有哪些流行的算法 1.5 Hash算法的碰撞 ...
- php后台开发(二)Laravel框架
php后台开发(二)Laravel框架 为了提高后台的开发效率,往往需要选择一套适合自己的开发框架,因此,选择了功能比较完善的Laravel框架,仔细学来,感觉和Python语言的框架Django非常 ...
- 【Visual C++】游戏开发笔记二十七 Direct3D 11入门级知识介绍
游戏开发笔记二十七 Direct3D 11入门级知识介绍 作者:毛星云 邮箱: happylifemxy@163.com 期待着与志同道合的朋友们相互交流 上一节里我们介绍了在迈入Dire ...
- PCL-1.8.1从源码搭建开发环境二(FLANN库的编译)
原文首发于微信公众号「3D视觉工坊」,PCL-1.8.1从源码搭建开发环境二(FLANN库的编译) 首先,快速近似最近邻搜索库FLANN-Fast Library for Approximate Ne ...
- 蓝鸥Unity开发基础二——课时20 接口
蓝鸥Unity开发基础二--课时20 接口 一.接口 使用interface关键字定义接口 接口定义一组成员单不直接实现它们 二.实现接口 实现接口的任何类都必须实现其所有的成员方法 接口不能直接实例 ...
最新文章
- 正则表达式——全部符号解释(详解)
- 如何在Hadoop上编写MapReduce程序
- 安川西格玛7驱动器手册_什么是伺服驱动器?选型的原则有哪些?
- cmd imp导入dmp文件_cmd 导入oracle数据的dmp文件
- 2017.4.26 组合数问题 思考记录
- iis7 64位 操作excel的一系列问题(未完待续)
- loadrunner提示:Cannot save the license information because acceses to the registry is denied
- mysql中的模糊查询(非原创)
- springboot国际化04
- 固定尺寸内存块的缓冲队列类及C++实现源代码
- 三轴合并_用两套乐高60107合并成铰接式云梯消防车,看看和60112有什么区别
- 对Python的初认识以及期待
- 对于处理上传图片添加水印的简单操作
- PowerPoint的巧妙使用就可造就一场经济而又专业的知识竞赛场面
- php 获取access token,百度应用获取Access Token
- chrome插件商店(Chrome插件商店)
- Nachos Lab3 同步机制
- win10一键激活,解除SymantecEndpointProtection的自动拦截
- java程序员转正述职报告PPT
- 使用Vim/Neovim编辑二进制文件
热门文章
- 回溯法 —— 算法框架及应用
- UnityShader9.1:光照基础实例
- bzoj 1706: [usaco2007 Nov]relays 奶牛接力跑(倍增floyd)
- 51nod-1065:最小正子段和
- Rabbitmq基本原理和架构
- matlab2c使用c++实现matlab函数系列教程-disp函数
- -函数-MATLAB提供的函数/主子函数/匿名-嵌套函数
- 配置Sublime Text3和MASM32编译汇编的问题汇总
- intel 酷睿core系列cpu的类型:U M H HQ MQ
- ZooKeeper CentOS7上安装