Introduction
This article provides information on how to configure different mail parameters in JobSchedulerManagedMailJob.
A Simple JITL Send Email Example
Following example shows a basic job configuration of JobSchedulerManagedMailJob. It is been configured to send email to a fix email Id along with fix email body and subject line.
When JobSchedulerManagedMailJob does not specify mail server host, port, smtp user and smtp user password, JITL job will apply default mail configuration from $SCHEDULER_DATA/config/factory.ini fils [smtp] section.
Configure subject or body text dynamically
As any other JITL job JobSchedulerManagedMailJob's parameters can also be configured dynamically using pre processor monitor. In following example we will dynamically set the value for parameters subject and body.
The outgoing mails body and subject will be dynamically configured depending upon week day.
Configure subject, body and attachment for incoming file
<job title="Send eMails" stop_on_error="no" order="yes" name="send_email_with_attachment"> <description > <include file="jobs/JobSchedulerManagedMailJob.xml"/> </description> <params > <param name="to" value="jobscheduler-admin-group@sos-berlin.com"/> <param name="from" value="gollum.sos@sos-berlin.com"/> <param name="from_name" value="JobScheduler Gollum"/> <param name="content_type" value="text/html"/> <param name="reply_to" value="mp@sos-berlin.com"/> </params> <script language="java" java_class="sos.scheduler.managed.JobSchedulerManagedMailJob"/> <monitor name="PreConfigureEmail" ordering="0"> <script language="javax.script:ecmascript"> <![CDATA[ function spooler_process_before() { try { // Check if any parameters are provided by order/task var orderParameters = spooler_task.order().params(); if( orderParameters.count() > 0 ) spooler_log.info( "Order Parameters given" ); var filePath = "" + String(orderParameters.value("scheduler_file_path")); spooler_log.info( " scheduler_file_path : " + filePath ); var fileParts = filePath.split("/"); var fileName = fileParts[fileParts.length-1]; spooler_log.info( "fileName : " + fileName ); var htmlHeader="<html><head></head><body>"; var htmlFooter="</body></html>\n\n"; var messageBodyTemplate="Dear Customer, <br>Please find the invoice file attached herewith. <br> FileName = PROCCESSED_FILE_OUT <br> Best regards <br> SOS GmbH <br> <br> <br> ** This is an automaticlly generated E-mail, Please do not reply. ** <br> ---------------------------------------------------------------------------------------------------- "; messageSubject="[ Invoice ] " + fileName; messageBody = htmlHeader + messageBodyTemplate.replace("PROCCESSED_FILE_OUT",fileName) + htmlFooter; spooler_log.info( ".. body: " + messageBody ); spooler_log.info( ".. messageSubject: " + messageSubject ); spooler_task.order().params().set_value("body",messageBody); spooler_task.order().params().set_value("subject",messageSubject); spooler_task.order().params().set_value("attachment",filePath); return true; } catch (e) { spooler_log.warn("error occurred : " + String(e)); return false; } } ]]> </script> </monitor> <run_time /> </job>
See also
- JobSchedulerManagedMailJob JITL job documentation