Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script Master Multiple Email Parameters

Featured Replies

I am trying to figure out how to extend SM SendEmail to also contain CC & BCC options?

  • Author

Ok I have figured out how to get the CC & BCC options working the next question is dealing with multiples. Multiple TO's CC's BCC's and ATTACHMENTS... any ideas?

  • Author

Process...

First I have a CF that creates:

SetEmailVariable ( from ; to ; cc ; bcc ; subject ; body ; html ; attach )


Let ( [



//USED IN GROOVY CODE

$sm_cc = cc ;

$sm_bcc = bcc ;

$sm_html = html;

$sm_attach = attach 



];



// Headers

SMSetVariable( "from" ; Case ( IsEmpty (  from  ); Case( IsEmpty( $$Email ) ;  "ERROR" ; $$Email ) ; from ) ) &

SMSetVariable( "to" ; to ) &



SMSetVariable ( "cc" ; cc )   &

SMSetVariable ( "bcc" ; bcc )   &



//Subject

SMSetVariable( "subject" ; subject ) &



// Body

SMSetVariable( Case( $sm_html ; "htmlBody" ; "body")  ; body ) &



//Attach

SMSetVariable( "attachmentPath" ; attach ) &



//SMTP

SMSetVariable( "smtpHost" ; "mail.domain.com" )



)







Then my groovy code is:





"import javax.mail.*;¶

import javax.mail.internet.*;¶

¶

Properties props = new Properties();¶

props.setProperty("mail.smtp.host", smtpHost);¶

MimeMessage msg = new MimeMessage(Session.getDefaultInstance(props));¶



msg.setSubject(subject);¶

msg.setFrom(new InternetAddress(from));¶

msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));¶" &



Case ( $sm_cc  ; "msg.setRecipient(Message.RecipientType.CC, new InternetAddress(cc));¶"  ) &

Case ( $sm_bcc  ; "msg.setRecipient(Message.RecipientType.BCC, new InternetAddress(bcc));¶" ) &





Case (  $sm_attach ; 

"Multipart content = new MimeMultipart();¶

// first the message body¶

MimeBodyPart bodyPart = new MimeBodyPart();¶

bodyPart.setText(body);¶

content.addBodyPart(bodyPart);¶

// then the attachment¶

MimeBodyPart attachmentPart = new MimeBodyPart();¶

attachmentPart.attachFile(attachmentPath);¶

content.addBodyPart(attachmentPart);¶

msg.setContent(content);¶ " ; 



Case ( $sm_html ; "msg.setContent( htmlBody, "text/html");¶" ; "msg.setText(body);¶" ) ) &



"Transport.send(msg);¶

return true;"

If there is a cleaner method to this - I am hoping to make this most generic so that it can be used in any different circumstance w/ or w/o CC / BCC / ATTACHMENTS and if the body is HTML

Your suggestions are welcome :

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.