using System;
using System.Net;
using GetOFFS.sg.com.ncs.webmail;
using Microsoft.Exchange.WebServices;
using Microsoft.Exchange.WebServices.Data;
namespace GetOFFS
{
public class Program
{
public static string url = "https://exchangeserveraddress/ews/Exchange.asmx";
static void Main(string[] args)
{
ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.Credentials = new NetworkCredential("username", "password", "domain");
esb.Url = url;
esb.RequestServerVersionValue = new RequestServerVersion();
esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010_SP1;
GetMessageTrackingReportRequestType gmt = new GetMessageTrackingReportRequestType();
GetMailTipsType gmType = new GetMailTipsType();
gmType.MailTipsRequested = new MailTipTypes();
gmType.MailTipsRequested = MailTipTypes.OutOfOfficeMessage;
gmType.Recipients = new EmailAddressType[1];
EmailAddressType rcip = new EmailAddressType();
rcip.EmailAddress = "target@emailaddress";
gmType.Recipients[0] = rcip;
EmailAddressType sendAs = new EmailAddressType();
sendAs.EmailAddress = "target@emailaddress";
gmType.SendingAs = sendAs;
GetMailTipsResponseMessageType gmResponse = esb.GetMailTips(gmType);
if (gmResponse.ResponseClass == ResponseClassType.Success)
{
if (gmResponse.ResponseMessages[0].MailTips.OutOfOffice.ReplyBody.Message != "")
{
//User Out
Console.WriteLine(gmResponse.ResponseMessages[0].MailTips.OutOfOffice.ReplyBody.Message);
}
else
{
//user In
}
}
}
}
}
从exchange server 获取out of office 信息
最新推荐文章于 2014-08-26 11:54:53 发布