This example demonstrate how to
- use the
MailNotificationService
to get informed while receive a new mail, - send a mail with an attached file
- Build the executable JAR using Maven
mvn clean install
. If you want to adjust the predefined configuration, usesrc/main/resources/application.yaml
before you build. - Run the application using
java -jar target/camunda-bpm-mail-example-print-service-<PROJECT_VERSION>.jar
. To use an external configuration, please find instructions in the guide. - Send a mail with the attached file which should be printed
- Check that a user task is created - complete it
- Now, check your mails
Also try to send a mail without attachment.
You can also use the ProcessIntegrationTest to run an example using a Spring Boot Test and a mocked mail server.
Spring Boot automatically instantiates the NotificationService as described here.
For this application, it is enough to just register a Bean of type Consumer<Mail>
here.
When the order is processed (i.e. complete user task 'print it') then the process sends a mail with the attached invoice (invoice.pdf
) using the mail-send
connector. The path of the invoice is stored in the process variable invoice
.
<bpmn:serviceTask id="ServiceTask_1ry54cw" name="send invoice">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="to">${mail.getFrom()}</camunda:inputParameter>
<camunda:inputParameter name="subject">invoice</camunda:inputParameter>
<camunda:inputParameter name="fileNames">
<camunda:list>
<camunda:value>${invoice}</camunda:value>
</camunda:list>
</camunda:inputParameter>
</camunda:inputOutput>
<camunda:connectorId>mail-send</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<!-- ... -->
</bpmn:serviceTask>