The following example is the entirety of the code for the Send Email Callout BIC.
package com.enterworks.services.calloutbic;
import java.util.ArrayList;
import java.util.HashMap;
import com.enterworks.apps.agents.bic.Work;
import com.enterworks.services.common.EmailUtil;
public class SendEmail extends BaseCalloutBic implements CustomCalloutBic {
private static final String EMAIL_ATTACHMENT = "email_attachment";
private static final String EMAIL_BODY = "email_body";
private static final String EMAIL_SEND_MESSAGE = "email_send_message";
private static final String EMAIL_SEND_STATUS = "email_send_status";
private static final String EMAIL_SUBJECT = "email_subject";
private static final String EMAIL_FROM = "email_from";
private static final String EMAIL_TO = "email_to";
private static final String EMAIL_CC = "email_cc";
private static final String CHANNEL_SEND_EMAIL_BIC = "Send Email BIC";
@Override
public String getDescription() {
return "Send an e-mail message to one or more recipients, identified by any combination of
" +
"e-mail addresses, Enable user logins, or Enable Groups. The e-mail is queued for " +
"processing based on the Email Manager settings.";
}
@Override
public void setInputParameters() {
this.addInputParameter(EMAIL_FROM, "Optional from address. If empty, global default will be
used.", null, null, null, false, 1, null);
this.addInputParameter(EMAIL_TO, "Comma-delimited list of any combination of e-mail
addresses, " +
"Enable user logins, or Enable Group names.", null, null, null, true, 1, null);
this.addInputParameter(EMAIL_CC, "Comma-delimited list of optional CC e-mail address. If
empty, global default will be used.", null, null, null, false, 1, null);
this.addInputParameter(EMAIL_SUBJECT, "Subject line for e-mail", null, null, null, true,
1, null);
this.addInputParameter(EMAIL_BODY, "Body text for e-mail", null, null, null, true, 1,
null);
this.addInputParameter(EMAIL_ATTACHMENT, "Fully-qualified path to file to be attached to
the e-mail message", null, null, null, false, 1, null);
}
@Override
public void setOutputParameters() {
this.addOutputParameter(EMAIL_SEND_STATUS, "Results of e-mail send operation (SUCCESS or
FAIL)");
this.addOutputParameter(EMAIL_SEND_MESSAGE, "Detailed error message if email.send.status
is FAIL");
}
@Override
public boolean processWorkItem(Work work, HashMap inputProperties, HashMap
outputParameters, StringBuffer errors) {
// Retrive properties
this.logDebug(CHANNEL_SEND_EMAIL_BIC, "Inside processWorkItem.");
String emailFrom = this.getParameter(inputProperties, EMAIL_FROM, null);
String emailTo = this.getParameter(inputProperties, EMAIL_TO, null);
String emailCc = this.getParameter(inputProperties, EMAIL_CC, null);
String emailSubject = this.getParameter(inputProperties, EMAIL_SUBJECT, null);
String emailBody = this.getParameter(inputProperties, EMAIL_BODY, null);
String emailAttachment = this.getParameter(inputProperties, EMAIL_ATTACHMENT, null);
logDebug(CHANNEL_SEND_EMAIL_BIC, "emailFrom=" + emailFrom + " emailTo=" + emailTo + "
emailCc=" + emailCc +
" emailSubject=" + emailSubject + " emailBody=" + emailBody + " emailAttachment=" +
emailAttachment);
if (EmailUtil.saveEmail(emailFrom, emailTo, emailCc, emailSubject, emailBody,
emailAttachment)) {
// Email successfully sent
outputParameters.put( EMAIL_SEND_STATUS, "SUCCESS");
} else {
outputParameters.put(EMAIL_SEND_STATUS, "FAIL");
outputParameters.put(EMAIL_SEND_MESSAGE, "Failed to send e-mail");
}
return true;
}
}