Support > Repository > Business logic > Send an email
ja | en

I will explain how to send mail from a script. R7.9

MailMessageManager is a utility class for sending mail.You can use this from a script.

var replaceMap = new java.util.HashMap();
replaceMap.put("$${{message}}", "Hello Wagby");
var mailman = p.appctx.getBean("MailMessageManager");
mailman.send("model1_update", replaceMap, errorManager, "Execute Script ", p);
  • The first line replaceMap is an instance of the Java standard class java.util.HashMap.Set rules to replace placeholders prepared in the mail template.The key part is the placeholder name and the value part is the value (replacing the placeholder).
  • In the second line, we set the value of the placeholder.When entering using the editor provided as a standard in Designer, please write the key part of replaceMap as $$ {{...}}.The actual output file is $ {...}.
  • We are acquiring the MailMessageManager object in the third line.
  • Mail is sent on line 4.The arguments of the send method are described below.
  • Although not used in the above example, the return value of mailman.send is boolean type.If the mail transmission is successfultrue.If it failsfales.

Argument of send method of MailMessageManager

argument Description
1 Specify the mail template identifier.
2 Specify the replacement map of placeholders prepared in the script.
3 An object that handles error messages.It can be used implicitly in scripts.Please specify this way.
4 When an error occurs, information is output to the log file, but a character string (log header) embedded at the head of the message of the log file at that time.It can be used to search log files.Please specify an arbitrary character string.To make the log file easier to see, you can add one space at the end.
5 P is a special object that can be used implicitly in scripts.Please specify this way.

Return value of MailMessageManager

If the mail transmission is successfultrueWill be returned.If it failsfalseWill be returned.