您的位置:首页 > 其它

Microsoft Exchange Server 以及 EWS 会议信息 拼接总结

2014-12-09 11:26 417 查看
1. Microsoft Exchange Server简介

Microsoft Exchange Server 是个消息与协作系统。Exchange server可以被用来构架应用于企业、学校的邮件系统或免费邮件系统。

Exchange Server主要版本有2003,2007,2010,2013以及云环境的Exchange Online。

我们主要与Exchange Server进行互动,进行会议室相关的会议预定信息的读取。

 

2.Outlook进行会议室预定及会议预定

   需要理解的是Exchange Server本身是提供邮件服务的服务器,用户真正使用和接触的是Outlook或者是网页版的Outlook。

   用户通过Outlook进行会议预定的步骤如下(来自百度):
http://jingyan.baidu.com/article/4b52d7026e5beffc5c774bc1.html
3.Outlook进行会议室预定及会议预定的说明

   与会议信息相关的是 会议的参与人,会议的主题,会议的时间,会议的地址。

   会议的参与人:收件者的邮箱地址

   会议的地址: 会议室的电子邮箱地址

 

4.开始与Exchange Server进行拼接,获取会议室的会议预定信息。

我们是通过EWS与Exchange Server进行拼接,获取会议室的信息;如果有足够的权限,也能增、删、改会议室的预订信息。

EWS全称是Exchange Web Service,各种版本的Exchange Server都提供,而且几乎都一样。(这样我们开发一次拼接程序,各种版本的exchange server都能使用)。而且MSDN上有许多EWS拼接相关的C#代码。

Exchange Server也提供其他的拼接方式,相对EWS感觉学习和使用难度比较大。

 

5.拼接读取会议信息C#代码例子:

class Program
{
public void GetExchangeBinding()
{
//连接exchange server
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

service.Credentials = new WebCredentials("yonghuyouxiang@aaa.net",
"123456");//需要读权限
// 指定Exchage服务的url地址,Exchange Online;其他版本就是Exchange Server的ip地址
service.Url = new Uri("https://***.outlook.com/EWS/Exchange.asmx");
//根据会议室名登陆相应的exchange server
FolderId cbfolder = new FolderId(WellKnownFolderName.Calendar, new Mailbox(roomaddress.getfullAddress()));//roomaddress.getfullAddress()是会议室邮箱的地址
//开始时间是当前时间
DateTime startDate = currentTime.Date;
//结束时间是今天
DateTime endDate = currentTime.Date.AddDays(Convert.ToDouble(1));
FindItemsResults findAppoint = null;
try
{
findAppoint = service.FindAppointments(cbfolder, new CalendarView(startDate, endDate, 300));
}
catch (Exception ex)
{
Console.WriteLine(ex);
Console.WriteLine(ex.Message + roomaddress.getfullAddress());
}
if (findAppoint != null && findAppoint.MoreAvailable) //若还有更多,则扩容到1000个会议信息
{
findAppoint = service.FindAppointments(cbfolder,
new CalendarView(startDate, endDate, 1000));
}

if (findAppoint != null && findAppoint.Items.Count > 0)
service.LoadPropertiesForItems(findAppoint.Items, new PropertySet(AppointmentSchema.Location, AppointmentSchema.Body, AppointmentSchema.Organizer, AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Body, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Body, AppointmentSchema.IsRecurring, AppointmentSchema.Recurrence, AppointmentSchema.IsCancelled));
if (findAppoint != null && findAppoint.Items.Count > 0)
foreach (Appointment a in findAppoint)
{
a.Load();
if (a.IsCancelled)
continue;

if (a.Subject == null)
{
a.Subject = "无主题会议";
}
}
}
}

//该类用于通过CA验证,正对于没有正常安装证书服务器的Exchange服务器。
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
public TrustAllCertificatePolicy()
{ }

public bool CheckValidationResult(ServicePoint sp,
System.Security.Cryptography.X509Certificates.X509Certificate cert,
WebRequest req, int problem)
{
return true;
}
}//end of class TrustAllCertificatePolicy
}
////////////////////////////////////////////////////
//a.Start       会议开始时间
//a.End         会议结束时间
//a.Location    会议地址
//a.Subject     会议主题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: