forked from OutSystems/docs-product
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(non-master content) Adding attachments to emails (OutSystems#247)
* New file + TOC * More content * Typo * Edited reference * Instuctions added * More content We'll blur the sample env name and user name soon. * More content + images Removed internal info from a screenshot. * Updated highlights * Tweaks + prereqs update * More on prereqs
- Loading branch information
Showing
9 changed files
with
121 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
summary: Learn how to add attachments to emails. | ||
tags: support-application_development | ||
--- | ||
|
||
# Adding email attachments | ||
|
||
An email attachment is a file users can open and save to their devices. For example, you can send a PDF file in the email for users to view and print the content. | ||
|
||
Send email attachments by providing the list of files in the **Attachments** section of the **Send Email** node. Define the file name, content, and media type of an attachment as the [Attachment data structure](#attachment-data-structure). | ||
|
||
In the **Attachments** section of the **Send Email**, you can add: | ||
|
||
* One or more inline attachments. Do this to attach a static file that changes rarely, like a PDF embedded in the app resources. See: [Attaching a single file](#attaching-a-single-static-file) | ||
|
||
* A list of attachments. Do this when you need to get multiple files from the database and send them at once, like several images from the product catalog See: [Attaching multiple files](#attaching-multiple-files) | ||
|
||
|
||
## Attaching a file | ||
|
||
To attach a file to an email, do the following in Service Studio: | ||
|
||
1. In the **Logic** tab, open the action that sends the email and select the **Send Email** node. | ||
|
||
<div class="info" markdown="1"> | ||
|
||
To learn more about creating emails, see [Managing emails](managing.md). For creating logic that sends emails, see [Sending emails](sending.md). | ||
|
||
</div> | ||
|
||
1. In the **Send Email** properties, locate the **Attachments** section and move your pointer over the **Attachments** list. A plus icon shows with the "add list item" tooltip. | ||
|
||
![Adding attachments in the Send Email action](images/email-attachment-inline-ss.png?width=495) | ||
|
||
1. Click the plus icon next to the **Attachments** list to add a new item. Service Studio adds a new Attachment item and labels it with zero. | ||
|
||
1. Move your mouse over the item you added in the **Attachment** list. Click the plus icon to expand. | ||
|
||
![Attachment properties](images/email-attachment-add-list-ss.png?width=315) | ||
|
||
1. Enter the information to define the file name, content, and media type of the email attachment. For more information about the Attachment properties, see [Attachment data structure](#attachment-data-structure). | ||
|
||
![Attachment properties](images/email-attachment-properties.png?width=320) | ||
|
||
Here are example properties to attach a PDF file from the module resources: | ||
|
||
* **FileName**: `"sample.pdf"`. | ||
* **FileContent**: `Resource.sample_pdf.Content`. | ||
* **MimeType**: `"application/pdf"` | ||
|
||
<div class="info" markdown="1"> | ||
|
||
To add a file to the module resources, go to the **Data** tab and right-click **Resources**, then select **Import Resources**. | ||
|
||
</div> | ||
|
||
|
||
## Attaching multiple files | ||
|
||
To attach several files to an email, create a List with the Attachment data structure and then pass the list to the **Attachments** property of the **Send Email** action. | ||
|
||
<div class="info" markdown="1"> | ||
|
||
The example references the **Sample_ProductImage** Entity from **OutSystemsSampleDataDB**, a standard sample data module in the OutSystems cloud. The text attribute **FileName** is the file name of the image attachments, and binary **FileContent** is the content. | ||
|
||
</div> | ||
|
||
In the following example, Service Studio fetches the images from the database with an Aggregate and then sends it in an email: | ||
|
||
1. In the **Logic** tab, open the action that sends the email and drag an Entity before the **Send Email** node. Service Studio places an Aggregate in the logic flow. | ||
|
||
![Getting data from database](images/email-attachment-getting-from-database.png?width=500) | ||
|
||
<div class="info" markdown="1"> | ||
|
||
Enter a value in the **Max. Records** property. For example, enter `5` to get five records for five attachments in the email. Leave the field empty to get all the records. | ||
|
||
</div> | ||
|
||
1. In the properties of the **Send Email** node, double-click the **Attachments** list. The expression editor opens. | ||
|
||
![Getting data from database](images/email-attachments-list.png?width=315) | ||
|
||
1. In the expression editor, select the output List from your Aggregate. For example, `GetSampleProductImages.List`. Expectedly, Service Studio shows an error with a message that you need to use the Attachment List data type. Click **Done** to close the editor and move on to the next step to map the values and resolve the error. | ||
|
||
1. In the Attachment section of Send Email, map the attributes so Service Studio knows which values pass to the attachments. You need to specify binary content and the file name. The MIME type is optional, but providing it lets more email clients handle the attachment. | ||
|
||
![Mapping the values to the attachment data structure](images/email-attachment-mapping.png?width=315) | ||
|
||
|
||
## Reference | ||
|
||
More information related to attachments. | ||
|
||
## Attachment data structure | ||
|
||
Use the Attachment data structure to pass information about files between the logic elements that handle emails. | ||
|
||
| Name | Data type | Notes | | ||
| ----------- | ----------- | -------------------------------------------------------------------------------------------------------- | | ||
| FileContent | Binary Data | Content that the platform embeds as the attachment. | | ||
| FileName | Text | The file name of the attachment to show in the email. For example, `"image.png"`. | | ||
| MimeType | Text | Media type identifier. For example, `"image/png"`. Enter to tell the email readers how to handle the content, as this can help prevent errors in some clients. Leave empty to let the email clients handle the detection. | |
Binary file added
BIN
+12.5 KB
src/develop/logic/emails-reactive/images/email-attachment-add-list-ss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+66.8 KB
...develop/logic/emails-reactive/images/email-attachment-getting-from-database.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.5 KB
src/develop/logic/emails-reactive/images/email-attachment-inline-ss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.5 KB
src/develop/logic/emails-reactive/images/email-attachment-mapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14 KB
src/develop/logic/emails-reactive/images/email-attachment-properties.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters