无法使用EWS设置持续时间 [英] Not able to set Duration using EWS
本文介绍了无法使用EWS设置持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我关注msdn aricle并且我无法设置OOF的持续时间,其余一切在代码中工作,它设置消息&激活OOF而不是持续时间,还有其他选择吗?
I am following the msdn aricle and I am not able to set the duration of the OOF, rest everything else works in the code, it sets the message & activates the OOF but not the duration, Are there any other alternatives?
MSDN http://msdn.microsoft.com/en-us/library/aa563356(EXCHG.80).aspx
MSDN http://msdn.microsoft.com/en-us/library/aa563356(EXCHG.80).aspx
此致,
推荐答案
在线样本不起作用。使用自动生成的代理,请尝试以下方法,但最简单的方法是使用EWS托管API。
The code in the online sample doesn't work. With auto-generated proxies, try the below, but the easiest way is to use the EWS Managed API.
static void Main(string[] args)
{
ExchangeServiceBinding service = new ExchangeServiceBinding();
service.UseDefaultCredentials = true;
service.Url = "https://server/EWS/Exchange.asmx";
UserOofSettings oofSettings = new UserOofSettings();
oofSettings.ExternalAudience = ExternalAudience.None;
// ExternalReply must be specified
oofSettings.InternalReply = new ReplyBody();
oofSettings.InternalReply.Message = "Test";
// ExternalReply must be specified, even if it's only an empty string and even if
// ExternalAudience is set to None
oofSettings.ExternalReply = new ReplyBody();
oofSettings.ExternalReply.Message = string.Empty;
// Duration should only be specified when OofState is set to scheduled
oofSettings.OofState = OofState.Scheduled;
oofSettings.Duration = new Duration();
// Duration.StartTime and EndTime must be in UTC
oofSettings.Duration.StartTime = DateTime.Now.AddHours(1).ToUniversalTime();
oofSettings.Duration.EndTime = DateTime.Now.AddHours(2).ToUniversalTime();
SetUserOofSettingsRequest request = new SetUserOofSettingsRequest();
request.Mailbox = new EmailAddress();
request.Mailbox.Address = "user@contoso.com";
request.UserOofSettings = oofSettings;
SetUserOofSettingsResponse response = service.SetUserOofSettings(request);
if (response.ResponseMessage.ResponseCode == ResponseCodeType.NoError)
{
Console.WriteLine("Success");
}
else
{
Console.WriteLine("Error: " + response.ResponseMessage.ResponseCode.ToString() + "\n" + response.ResponseMessage.MessageText);
}
Console.ReadLine();
}
这篇关于无法使用EWS设置持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文