October 27, 201510 yr 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
October 27, 201510 yr 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, 201510 yr by john renfrew
October 27, 201510 yr Author 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
October 27, 201510 yr 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.
October 31, 201510 yr Author 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
October 31, 201510 yr 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.
November 1, 201510 yr Author 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
November 7, 201510 yr Author 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
November 7, 201510 yr 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...
November 11, 201510 yr Author Thanks John. That sounds about right. Will post what the exchange solution if that's where it's going wrong. Ta
November 13, 201510 yr Author Yup it was exchange, it didn't have a problem with multiple addresses but just external ones. Ta
Create an account or sign in to comment