Tutorial 08: Send an email
Introduction
This tutorial is targeting
Low-code developers benefit significantly from the capability to send emails directly from a pipeline, a feature that enhances communication, automation, and workflow management within applications and develop the following Automated Notifications, Workflow Integration, Reporting, Scalability.
What you will learn
In this tutorial, you will learn how you can send emails from a pipeline, with and without attachments.
Step 1: Send a simple email via automation pipeline
Login to the portal https://NAMESPACE.pipeforce.net
Navigate to LOW CODE → Workbench
Select the node of your app or create a new one.
Click the plus icon at the top of the tree.
Name your Pipeline and Then ClickÂ
Create
The new property has been created, and the content editor was opened for you.
Now copy and paste this content into the editor, and overwrite any existing data there by this:
pipeline:
- mail.send:
to:"your@domain.tld"
subject:"Test email"
message:"This is a simple email, sent from a pipeline."
ReplaceÂ
your@domain.tld
 by your real email address.ClickÂ
SAVE
 and thenÂRUN
 to execute the pipeline.
10. After a while, you should have received an email similar to this, decorated with the default layout:
Step 2: Send attachments with the email
In this step, you will learn how to add attachments to such an email pipeline. For this, we will upload a PDF document to drive first, which will be used as an attachment.
Login to the portal https://NAMESPACE.pipeforce.net
Open Files / Drive.
Upload a PDF file with nameÂ
invoice.pdf
 into the root folder.Change your pipelineÂ
send-email
 to this:
pipeline:
- drive.read:
path: "invoice.pdf"
- mail.send:
to: "your@domain.tld"
subject: "Test email"
message: "This is a simple email, sent from a pipeline."
attachments: "${body}"
As you can see, we added the commandÂ
drive.read
 to read the PDF from drive into the body of the pipeline (which happens automatically for you). Additionally, we added the parameterÂattachments
 to theÂmail.send
 command. As value, the PEL expressionÂ${body}
 is used. This expression points to the body of the current pipeline where the PDF document was loaded to. You can add multiple attachments by adding them separated by a comma. You can also point to resources inside the property store by using the uri formatÂuri:property:path/to/resource
.ClickÂ
SAVE
 and thenÂRUN
.After a while, you should receive again an email, but this time with the PDF attachment.
Step 3: Set dynamic text in the email
Sometimes it is necessary to put dynamic text to emails. The easiest way in PIPEFORCE to do this, is by using the Pipeline Expression Language (PEL) .
In this step, we will add the currently logged-in user as the from
email field, so that the recipient can easily reply to you with the current date and time in the email text using PEL:
Change your pipeline send-email to this:
pipeline:
- drive.read:
path: "invoice.pdf"
- mail.send:
to: "your@domain.tld"
replyTo: "${@user.email()}"
fromName: "${@user.displayName()}"
subject: "Test email"
message: "This is a simple email, sent on ${@date.now('dd.MM.YY, HH:mm')}"
attachments: "${body}"
As you can see, we did several changes in the pipeline:
We added the parameterÂ
replyTo: "${@user.email()}"
. Its value will be replaced by the email address of the currently logged-in user, so the recipient can simply press the reply button to reply to this email.We added the parameterÂ
fromName: "${@user.displayName()}"
. Its value will be replaced by the display name of the currently logged in user.Finally, we added the PEL expressionÂ
${@date.now('dd.MM.YY, HH:mm')}
 to the email message, in order to display the current date and time dynamically inside the email.ClickÂ
SAVE
 and thenÂRUN
.After a while you should receive an email similar to this:
Â
Â