sal88 Posted October 27, 2015 Posted October 27, 2015 I'm using the SM's SendEmailHTMLFormatted function to great effect, I'm enjoying just just having the single script step. However I can't work out how to have multiple recipients in the 'to' parameter. It says in the function description in SM: "Additional possibilities include sending to multiple recipients, SMTP authentication, multi-part emails, attachments, and much more." I've tried separate multiple email addresses with a semi colon and comma but no joy. Any help appreciated. Thanks
john renfrew Posted October 27, 2015 Posted October 27, 2015 (edited) change/adapt the function? if (to){ sendto = to.tokenize('\n') sendto.each{ msg.addRecipient(Message.RecipientType.TO, new InternetAddress(it)) }//end each }//end if Edited October 27, 2015 by john renfrew
sal88 Posted October 27, 2015 Author Posted October 27, 2015 Sorry to be vague but this is new to me. What language is that? Would it go in to the msg.setRecipient bit in the scriptmaster module editor? Thanks
john renfrew Posted October 27, 2015 Posted October 27, 2015 Its Groovy, the language that the plugin uses. in the Send Email (HTML-Formatted) module replace the line msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to)) with the code above, should work.
sal88 Posted October 31, 2015 Author Posted October 31, 2015 That works! Thank you so much. Just one more thing though, is it possible to have the separator as a comma? I've tried to replace '\n' with "," or ',' but to no avail. Does it only work when there is a line between each entry (as well as the comma)? Thanks
john renfrew Posted October 31, 2015 Posted October 31, 2015 Send it as a comma separated list, then the code would be. Works here. List is my preference. sendto = to.tokenize(',') What you are doing is turning the values you sent into an array (list) so you are then looping through that and for each one you are adding a :TO onto the msg.
sal88 Posted November 1, 2015 Author Posted November 1, 2015 Perfect, thank you! I think my mistake was putting the semicolon after the: }//end if Which I'm guessing would be ignored because of the '//'. Cheers
sal88 Posted November 7, 2015 Author Posted November 7, 2015 For some reason I can't get it to send to multiple recipients via our exchange server as the SMTP Server. For single addresses it is fine. Using a 3rd party SMTP provider outside the building is fine for multiple recipients. Any ideas? Also, is it OK to use double quotations for sendto = to.tokenize(',') i.e. to.tokenize(",") Thanks
john renfrew Posted November 7, 2015 Posted November 7, 2015 Makes no difference, except makes it easier to troubleshoot the end function as FMP will later escape any " characters to \", and the point about Groovy is that its about making it as easy as possible to write the code - which is also why no need to put ; at the end of a line, and why there are lots of Groovy methods which are much simpler to write than in Java Your issue might be more to with Exchange than the code itself...
sal88 Posted November 11, 2015 Author Posted November 11, 2015 Thanks John. That sounds about right. Will post what the exchange solution if that's where it's going wrong. Ta
sal88 Posted November 13, 2015 Author Posted November 13, 2015 Yup it was exchange, it didn't have a problem with multiple addresses but just external ones. Ta
Recommended Posts
This topic is 3641 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now