首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从移动设备设置Outlook不在办公室

从移动设备设置Outlook不在办公室
EN

Stack Overflow用户
提问于 2014-06-05 21:40:00
回答 2查看 526关注 0票数 0

我的任务是编写一个移动应用程序(使用xamarin),允许您将Outlook设置为不在办公室。我发现的许多示例都在使用互操作,它不会在移动应用程序中构建。有人能推荐一种替代方法吗?

EN

回答 2

Stack Overflow用户

发布于 2014-06-05 21:46:30

您可以使用Exchange Web服务来执行此操作。

来自http://msdn.microsoft.com/en-us/library/office/aa563356(v=exchg.140).aspx

代码语言:javascript
复制
static void SetOOF(ExchangeServiceBinding service)
{
    // Identify the user mailbox for which to set OOF information.
    EmailAddress emailAddress = new EmailAddress();

    emailAddress.Address = "donhall@example.com";
    emailAddress.Name = String.Empty;

    UserOofSettings OOFSettings = new UserOofSettings();

    // Identify the time that a user is OOF 
    Duration duration = new Duration();
    duration.StartTime = DateTime.Now;
    duration.EndTime = DateTime.Now.AddHours(4);
    OOFSettings.Duration = duration;

    // Identify the external audience.
    OOFSettings.ExternalAudience = ExternalAudience.Known;

    // Create the reply messages.
    ReplyBody internalReply = new ReplyBody();
    ReplyBody externalReply = new ReplyBody();
    externalReply.Message = "This is my external OOF reply";
    internalReply.Message = "This is my internal OOF reply";

    OOFSettings.ExternalReply = externalReply;
    OOFSettings.InternalReply = internalReply;

    // Set OOF state.
    OOFSettings.OofState = OofState.Enabled;

    // Create the request.
    SetUserOofSettingsRequest request = new SetUserOofSettingsRequest();
    request.Mailbox = emailAddress;
    request.UserOofSettings = OOFSettings;

    try
    {
        // Send the request and return the response.
        SetUserOofSettingsResponse response = service.SetUserOofSettings(request);
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}
票数 0
EN

Stack Overflow用户

发布于 2014-06-06 20:16:41

艾伦-感谢你的回复。我终于让它工作了,但这个库似乎已经被修改了,所以如果其他人需要它,这里是我的代码:

代码语言:javascript
复制
  ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);

        service.Url = new Uri("https://<server>/EWS/Exchange.asmx");

        EmailAddress emailAddress = new EmailAddress();

        emailAddress.Address = "nick.wright@<domain>";
        emailAddress.Name = String.Empty;

        OofSettings OOFSettings = new OofSettings();

        OOFSettings.Duration = new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1));

        OOFSettings.ExternalAudience = OofExternalAudience.All;

        OofReply internalReply = new OofReply();
        OofReply externalReply = new OofReply();

        externalReply.Message = "This is my external OOF reply";
        internalReply.Message = "This is my internal OOF reply";

        OOFSettings.ExternalReply = externalReply;
        OOFSettings.InternalReply = internalReply;

        OOFSettings.State = OofState.Disabled;

        try
        {
            service.SetUserOofSettings("nick.wright@<domain>", OOFSettings);
        }
        catch (Exception ex)
        {
        }

我遇到了几个错误。首先,文档中的URL是不正确的,所以修复它:

exchange web service error - the remote server returned an error 405 method not allowed

其次,Exchange版本需要显式设置(虽然设置后,我可以将其设置为任何版本,并且它可以工作!?!)

http://social.technet.microsoft.com/Forums/exchange/en-US/df5c0c5e-1ea6-4ee9-824c-e8cb4930e291/ews-managed-api-error-exchange-server-doesnt-support-requested-version?forum=exchangesvrdevelopment

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24061821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档