Use Email Signatures in Scripts
Whenever you send email from scripts you will want to add a matching signature (email footer) to your email text. These footers are added to email texts automatically when you answer emails with todo4teams. You will have to add them programatically in scripts, which is fairly easy. In the "Receive Action" of the mailbox configuration, the solution is right at hand. At first you access the footer of the mailbox, by which the ticket was created:
The expression task.source.sourcemailbox is the email box that received the message. The attribute footer contains the signature text. From any other scripts you will need to add a few lines more.
Please have a look at the list of mailboxes configured and note the id of the one, which footer you want to use. Let's say the ID is 2 here. Get the signature text as follows:
if (box != null && box.isActive()) {
var footer = box.footer;
...
}
The variable footer now contains the signature text. Add it to the email text and send the message using the sendMail methods of the helper object (see the example below). Set the message text accordingly and set the parameter isHTML to true if your message should be send in HTML format, or false otherwise. A good starting point for your own solution is the following snippet:
if (box != null && box.isActive()) {
var subject = "Ihre Anfrage an / Your request to "+task.source.sourcemailbox.emailAddress;
var text = "Betreff Ihrer Nachricht / Subject of your request:<br/><pre>"+ message.getSubject()+"</pre>";
text += ...
text += ...
text += "\n<br/><br/>"+ box.footer;
var toEmail = message.getFrom()[0].getAddress();
helper.sendmail(
box.emailAddress, // The email address this mail is sent from
subject, // The subject
text, // The body of the email
toEmail, // The email address this mail is sent to
null, // No CC
null, // No BCC
true // Email is HTML formatted
);
}