cancel
Showing results for 
Search instead for 
Did you mean: 

Optional email task CC addresses

ericsnyder
Champ on-the-rise
Champ on-the-rise
I have an email task. My "To" field is required but the "CC" field is optional on my form. When I do not select any email addresses for the "CC" field then I get an exception:
<blockquote>
Caused by: org.activiti.engine.ActivitiException: Could not add  as cc recipient
   at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.addCc(MailActivityBehavior.java:144)
   at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:59)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:86)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:530)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:525)
</blockquote>
and later…
<!–break–>

<blockquote>
Caused by: org.apache.commons.mail.EmailException: Illegal address
   at org.apache.commons.mail.Email.createInternetAddress(Email.java:605)
   at org.apache.commons.mail.Email.addCc(Email.java:806)
   at org.apache.commons.mail.Email.addCc(Email.java:789)
   at org.apache.commons.mail.Email.addCc(Email.java:769)
   at org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior.addCc(MailActivityBehavior.java:142)
   … 126 more
Caused by: javax.mail.internet.AddressException: Illegal address in string ``''
   at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:108)
   at org.apache.commons.mail.Email.createInternetAddress(Email.java:578)
   … 130 more
</blockquote>

I have tried numerous conditionals in the JUEL (none worked) and tried having my bean return "" for the email addresses. Is there a way that I can optionally set the "CC" field in a mail task?
3 REPLIES 3

ericsnyder
Champ on-the-rise
Champ on-the-rise
For the time being I have just set my code to return an email address as a default. I do wonder if a check to see by activiti to see if a value has been passed (or a value of length > 3) before it sends the values to Apache rather than just assuming that the value has a valid email address in it. I have not checked the activiti engine code to see what is happening there.

trademak
Star Contributor
Star Contributor
Cc is also an optional field in the MailActivityBehavior class. But if you set an expression or so, then it might be that it returns an empty string and this is added to the cc field and you get the error. Did you also try to set the cc variable to null?

Best regards,

ericsnyder
Champ on-the-rise
Champ on-the-rise
<blockquote>Did you also try to set the cc variable to null?</blockquote>Yes, I get the same result.