Date- and time-controlled email reply (absence note)


In addition to the tutorial for Automatic responses to emails  there is the possibility to provide emails responses with a date-controlled or time-controlled parameterization.
This can make sense particularly in times of restricted business activity, e.g. In holidays as a kind of absence note.

Please make the corresponding settings in the receive action of the affected mailbox.
The following script allows you to specify the desired time interval during which a defined response e-mail is to be sent when a request is received:

    function isHolidays()
    {
       var startDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2016.12.23 13:00");
       var endDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2017.01.03 00:00");
       var now = new java.util.Date();
       return now.after(startDate) && now.before(endDate);
    }


if (isHolidays())
 {
gewünschte Aktion...
 }

In the line

var startDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2016.12.23 13:00");

the start date and the start time are defined.

In the line

var endDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2017.01.03 00:00");

the end date and the end time are defined.

The desired action

{
 gewünschte Aktion...
}

should  now be defined, in our case the sending of an automated email resonse. For this, the script from the Automatic responses to emails  tutorial can simply be copied.

In sum, this now results in the following script, the text of the response email you may adapt to your own needs:

function isHolidays()
    {
       var startDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2016.12.23 13:00");
       var endDate = new java.text.SimpleDateFormat("yyyy.MM.dd HH:mm").parse("2017.01.03 00:00");
       var now = new java.util.Date();
       return now.after(startDate) && now.before(endDate);
    }


if (isHolidays())
 {
var id = task.id;
var email = message.getFrom()[0].getAddress();
                           
var footer = task.source.sourcemailbox.footer;
             
var text = "<html><head></head><body><p>Sehr geehrte Damen und Herren,<br/><br/>\n";
text += "wir haben Ihre Anfrage erhalten und werden diese zeitnah abarbeiten.<br/><br/>";
text += "Bitte notieren Sie sich Ihre Ticketnummer: "+id+"<br/><br/>\n";
text += "Mit freundlichen Grüßen<br/>\n";
text += "Ihr todo4teams Team<br/></p><br/>\n";
text += "</p><br/>\n";

text += "Ihre Anfrage:<br/><pre>"+ message.getSubject()+"</pre>";

text += "\n<br/><br/>"+footer+"</body></html>";

helper.sendmail(
   task.source.sourcemailbox.emailAddress, // sender email address
  "Your request to "
  +task.source.sourcemailbox.emailAddress+" (ID: "+id+")", // subject
  text, // message
  email, // addressee
  null, // cc
  null, // bcc
  "support@bergener-bluma.de", // reply to
 true // html formatted message
);
 }

 

     

Child Pages