Community

Mail template for custom MailProducer

reply from Alejandro Guizar in jBPM Development - View the full discussion

Here is how you can specify a named template for a custom mail producer:

<mail name='send mail' class='org.example.CustomMailProducer'>
  <field name='templateName'><string value='rectify-template'/></field>
  <transition to='end' />
</mail>

Here is the custom mail producer code:

public class CustomMailProducer extends MailProducerImpl {
 
  private String templateName;
 
  public Collection<Message> produce(Execution execution) {
    MailTemplateRegistry templateRegistry = EnvironmentImpl
      .getFromCurrent(MailTemplateRegistry.class);
    setTemplate(templateRegistry.getTemplate(templateName));
    return super.produce(execution);
  }
}

It should be possible to inject a reference to the template registry into the bean, but it is not currently possible due to the way the custom mail producer is parsed. I will fix this in JBPM-2844.

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community