Exchange 2007新特性与二次开发
2007-12-03 16:26:40 来源:WEB开发网(2)设置ExchangeServiceBinding代理类。
完成Web引用后,我们就可以用以下的语句来完成Service的绑定。
ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.Credentials = new NetworkCredential("administrator", "J$p1ter", " DFQVPI-dom");
esb.Url = "https://bjextest043/EWS/exchange.asmx";
(3)创建并调用操作。
CreateItemType createEmailRequest = new CreateItemType();
.
.
.
MessageType message = new MessageType();
message.Subject = "Mail Test";
.
.
.
createEmailRequest.Items.Items = new ItemType[1];
createEmailRequest.Items.Items[0] = message;
(4) 发送请求并处理响应。
CreateItemResponseType createItemResponse = esb.CreateItem(createEmailRequest);
接下来我们就以为用户创建邮件信息应用为例,向大家全面地展示一下如何利用Exchange Web Service进行二次开发。
private void SendMail(ExchangeServiceBinding esb)
{
//创建 CreateItem 的请求
CreateItemType createEmailRequest = new CreateItemType();
//确定 Mail的处理方式
createEmailRequest.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
createEmailRequest.MessageDispositionSpecified = true;
//确定发送信息存放的位置
createEmailRequest.SavedItemFolderId = new TargetFolderIdType();
DistinguishedFolderIdType sentitmes = new DistinguishedFolderIdType();
sentitmes.Id = DistinguishedFolderIdNameType.sentitems;
createEmailRequest.SavedItemFolderId.Item = sentitmes;
//创建存放数组
createEmailRequest.Items = new NonEmptyArrayOfAllItemsType();
//创建 e-mail 信息
MessageType message = new MessageType();
message.Subject = "Mail Test";
message.Body = new BodyType();
message.Body.BodyType1 = BodyTypeType.Text;
message.Body.Value = "TOoo Busy!!!!.";
message.Sender = new SingleRecipientType();
message.Sender.Item = new EmailAddressType();
message.Sender.Item.EmailAddress = "Administrator@DFQVPI-dom.extest.microsoft.com";
message.ToRecipients = new EmailAddressType[1];
message.ToRecipients[0] = new EmailAddressType();
message.ToRecipients[0].EmailAddress = Receiver;
message.Sensitivity = SensitivityChoicesType.Normal;
createEmailRequest.Items.Items = new ItemType[1];
createEmailRequest.Items.Items[0] = message;
try
{
// 创建绑定
ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.Credentials = new NetworkCredential("administrator", "J$p1ter", " DFQVPI-dom");
esb.Url = "https://bjextest043/EWS/exchange.asmx";
//发送CreateItem的请求
CreateItemResponseType createItemResponse = esb.CreateItem(createEmailRequest);
ArrayOfResponseMessagesType responseMessages = createItemResponse.ResponseMessages;
}
catch (Exception ex)
{
throw new Exception("Warning: " + ex.Message);
}
}
Exchange Web Service是一个新的开发技术,在未来的日子它会得到更效地发展和完善,如果大家有兴趣的话可以尽早投入到这项新技术中,经过自己的实践与思考,定会成为这项新技术的专家。
- ››Exchange Server 2010分层通讯簿(结构化通讯簿HA...
- ››Exchange2010恢复已删除的账号及邮箱
- ››Exchange 2010 邮件分类管理的实现与技巧
- ››Exchange 2010功能替代传统备份方案
- ››Exchange Server 2007 系列之一:简介与部署
- ››Exchange Server 2007系列之二:管理工具简介
- ››Exchange Server 2007系列之三:邮箱的创建及基本配...
- ››Exchange Server 2007 系列之四:邮箱的配置
- ››Exchange 2007 队列、队列事务日志文件超过临界值...
- ››Exchange服务器出故障,应如何监控
- ››Exchange的邮箱信息丢失了,应如何还原
- ››Exchange公用文件夹丢失了,应如何还原
更多精彩
赞助商链接