Send email to multiple recipients via mail connector

Dear Community,

I am using mail connector https://github.com/camunda/camunda-bpm-mail to send Mails. For one recipient it is working fine. However, I need to send the mail to multiple recipients.

First I tried to pass a java.util.List as Input Parameter “to”. This throws an Exception as a String is expected. I could solve it by converting the Mail Activity to a Sequential Multi Instance Activity. This works works, though it is not exactly, what I wanted. In this case for each recipient a separate mail is sent whereas I want camunda to send one mail with multiple recipients.

Any hint will be appreciated.

Looking at the underlying implementation, the to, cc and bcc fields should all take a list of email addresses separated by commas. You should be able to take your java.util.List and turn it into string of addresses delimited by commas.

Hi @jgigliotti,
I have a similar issue . I am getting the list of email addresses from a decision table (using collect policy). I am trying to use the output variable from the table in the “to” field of the mail connector . Tried the following :

  1. Use String Expression in the “to” field and variable #{approver} [which is the output variable from the decision table, and is a list] and rightly gave me a ClassCastException

java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader ‘bootstrap’)

at org.camunda.bpm.extension.mail.send.SendMailRequest.getTo(SendMailRequest.java:51)
2) Use List as the variable assignment type in the “To” field and provide #{approver} . It throws the same exception as above. the getTo() method of SendMailRequest is expected to return a String.

Is there a way to get around this or am I using the incorrect assignments?

Thank you
Romasha

Yes, like I mentioned above, you need to pass it a string composed of email addresses separated by commas, e.g.:

email1@example.com, email2@example.com, email3@example.com

Decision table outputs do not take a comma separated string .
DMN-01002 Unable to evaluate expression for language ‘juel’: ‘${“test1.test@abc.com”, “abc.def@abc.com”}’
So the alternative is to define rows for each person eligible to get that email , for a certain input , then use a collect policy and have it as a list but it does not work , when using the variable in the connector as a value for “To”. Though there is a “List” option in the connector for “To” but eventually it fails later.

Decision output not taking a comma separated list . Is that expected behavior ? My other option is to use a single distribution list instead of specific email addresses as a list or comma separated.

Sounds like you’re conflating two things. Instead of mapping the DMN output directly to the To field of the email connector, can you transpose the data in a delegate before feeding it into the email task? Before you do anything though, test it out and verify the string of comma separated email addresses works. I haven’t done so, I was merely looking at the extension’s source.

@romashatomar from the dmn output (list of email address) construct the string value separated by comma for each values in the list.

For example:

DMN result: [“a@a.com”, “b@b.com”]

into

a@a.com”, “b@b.com

will work.