Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Helper function for converting array to coma separated list
- function convertToComaSeparatedList (arrayList) {
- if ( arrayList == null || arrayList.length == 0) {
- return null
- }
- var outStr = "";
- for (var i=0; i < arrayList.length; i++) {
- outStr += arrayList[i] + ",";
- }
- if (outStr.length > 0){
- outStr = outStr.substring(0, (outStr.length - 1));
- }
- return outStr;
- }
- var message = new EmailMessage();
- // Override default settings if and only if input parameter is set
- if ( smtpHost != null && smtpHost.length > 0 ){
- message.smtpHost = smtpHost;
- }
- if ( smtpPort != null && smtpPort > 0 ){
- message.smtpPort = smtpPort;
- }
- if ( username !=null && username.length > 0){
- message.username = username;
- }
- if ( password != null && password.length > 0){
- message.password = password;
- }
- if ( fromName != null && fromName.length > 0){
- message.fromName = fromName;
- }
- if ( fromAddress != null && fromAddress.length > 0){
- message.fromAddress = fromAddress;
- }
- // Build Address Lists
- message.toAddress = convertToComaSeparatedList(toAddressList);
- message.ccAddress = convertToComaSeparatedList(ccList);
- message.bccAddress = convertToComaSeparatedList(bccList);
- // Set subject
- message.subject = subject;
- // Add text part of the email
- message.addMimePart(content,"text/html; charset=UTF-8");
- // Add attachment
- message.addMimePart(attachment, attachment.mimeType);
- // Send message
- message.sendMessage();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement