Discussion:
Unable to initialize SendEmail Function component from Script
Add Reply
Alwyn Lobo
2017-09-18 09:11:07 UTC
Reply
Permalink
Raw Message
Hello,

I am trying to initialize Send email function component with name "SendUAMReportEmail", from my script using the below code

try{
var sendEmail = system.getFunction("SendUAMReportEmail");
var returnObj = sendEmail.perform(null);
}catch(e){
task.logmsg("Error: " + e.toString());
}

Below error is displayed in the logs

13:05:15,360 INFO - Error: javax.naming.NameNotFoundException: CTGDKE218E Includes could not be found.

Please suggest where I am going wrong and what is the correct way to call a function.
John Dell'Oso
2017-09-19 00:12:50 UTC
Reply
Permalink
Raw Message
Hi,

Here's a function I've used for sending email via the SendEMail FC. I have the FC set up in passive mode. The name of the FC is EmailAdminNotificationFC in the code below.

function sendAdminNotification(from, to, subject, body_headline, work) {

// create mail entry and populate with appropriate values
var mailEntry = system.newEntry();

mailEntry.setAttribute("from", from);
mailEntry.setAttribute("recipients", to);
mailEntry.setAttribute("subject", subject);
//mailEntry.setAttribute("smtpServerHost", "mailhost.bbl.int");
//mailEntry.setAttribute("smtpServerPort", "25");

mailEntry.setAttribute("body", body_headline +
"User ID: " + work.user_ID + "\n" +
"Last Name: " + work.last_name + "\n" +
"First Name: " + work.first_name + "\n" +
"Email Address: " + work.email_address + "\n" +
"Mobile Number: " + work.mobile_number + "\n" +
"User Type: " + work.user_type + "\n" +
"Operation: " + work.operation + "\n" +
"Date/Time: " + system.formatDate(new Date(), "dd MMM yyyy hh:mm:ss aa" ));

// send the email
EmailAdminNotificationFC.getFunction().perform(mailEntry);
}

I'm not suggesting that you use this function, but the content contained within should be able to get you going. HTH.

Regards,
JD

Loading...