0

I have a client with a self-hosted 2010 Exchange Server. They want to have Auto Reply automatically turn on only between 5:00 PM and 8:00 AM. During these hours they do not want any notifications of any new emails to appear on their devices, but would like to still be able to check their email.

Is exchange configurable to do any of this or is there some software that can do this out of the box? Or will I need to have a custom solution developed?

David Murdoch
  • 492
  • 6
  • 19

1 Answers1

1

Out of the box no, but you can easily code that with EWS.

An example in C# to Set Out of Office message for one mailbox;

static void SetOOF(ExchangeService service)
{
    OofSettings myOOF = new OofSettings();

    // Set the OOF status to be a scheduled time period.
    myOOF.State = OofState.Scheduled;

    // Select the time period to be OOF.
    myOOF.Duration = new TimeWindow(DateTime.Now.AddDays(4), DateTime.Now.AddDays(5));

    // Select the external audience that will receive OOF messages.
    myOOF.ExternalAudience = OofExternalAudience.All;

    // Set the OOF message for your internal audience.
    myOOF.InternalReply = new OofReply("I'm currently out of office. Please contact my manager for critical issues. Thanks!");

    // Set the OOF message for your external audience.
    myOOF.ExternalReply = new OofReply("I am currently out of the office but will reply to emails when I return. Thanks!");

    // Set the selected values. This method will result in a call to the Exchange server.
    service.SetUserOofSettings("someone@example.com", myOOF);
}

With that example, you can see it's quite simple, you just have to use an admin's account that can impersonation all the mailbox to set the out of office message.

If you don't code, you can send with curl some XML too. Like shown there: Quick and Dirty UNIX Shell Scripting with EWS

  <?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <t:RequestServerVersion Version="Exchange2010_SP1" />
    </soap:Header>
    <soap:Body>
      <m:SetUserOofSettingsRequest>
        <t:Mailbox>
          <t:Address>someone@example.com</t:Address>
        </t:Mailbox>
        <t:UserOofSettings>
          <t:OofState>Scheduled</t:OofState>
          <t:ExternalAudience>All</t:ExternalAudience>
          <t:Duration>
            <t:StartTime>2011-10-29T18:45:08.243Z</t:StartTime>
            <t:EndTime>2011-10-30T18:45:08.243Z</t:EndTime>
          </t:Duration>
          <t:InternalReply xml:lang="en-US">
            <t:Message>I'm currently out of office. Please contact my manager for critical issues. Thanks!</t:Message>
          </t:InternalReply>
          <t:ExternalReply xml:lang="en-US">
            <t:Message>I am currently out of the office but will reply to emails when I return. Thanks!</t:Message>
          </t:ExternalReply>
        </t:UserOofSettings>
      </m:SetUserOofSettingsRequest>
    </soap:Body>
  </soap:Envelope>

Example from there

For the device notification on the other hand is something else, it's the device itself that do the push notification, not Exchange. For that part I can't help.

yagmoth555
  • 16,758
  • 4
  • 29
  • 50
  • This looks like it'll work, though I haven't tested yet. As for the other part of the problem, i'll probably just create a rule that moves emails received in the no-email-notification window to a folder and mark them as read, then each morning run a task that moves them back to the inbox and marks them as unread. – David Murdoch Aug 16 '16 at 20:45