Jump to content

Send HTML email with multiple recipients


This topic is 3031 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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 by john renfrew
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

 

Link to comment
Share on other sites

This topic is 3031 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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