Skip to content

Commit

Permalink
(non-master content) Adding attachments to emails (OutSystems#247)
Browse files Browse the repository at this point in the history
* 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
rmlos authored Jul 8, 2021
1 parent c137aac commit 6fcae08
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 17 deletions.
103 changes: 103 additions & 0 deletions src/develop/logic/emails-reactive/attachments.md
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. |
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.
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.
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.
34 changes: 17 additions & 17 deletions src/develop/logic/emails-reactive/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ tags: support-application_development, article-page

# Technical Preview - Emails in Mobile and Reactive Web Apps

You can create and send emails from Mobile Apps and Reactive Web Apps. In this technical preview, you can use basic formatting and navigation in your emails.

Continue reading about the emails in OutSystems or jump right to:

* [Prerequisites](#prerequisites)
* [Getting started](#getting-started)
You can create and send emails from Mobile Apps and Reactive Web Apps. In this technical preview, you can use basic formatting and navigation in your emails.

## Prerequisites

To use this feature, you must meet the following requirements:
To use this feature, you must meet the following requirements.

**General requirements**

* You're using Platform Server 11.12 or later.
* Your Service Studio is up to date.
* You have configured the SMTP server. See [Configure OutSystems to Send Emails](../../../extensibility-and-integration/configure-send-emails.md) for instructions.
* You have activated the [technical preview](https://success.outsystems.com/Support/Enterprise_Customers/Upgrading/Technical_Preview_features) **Emails for Mobile and Reactive** in LifeTime in **all environments**.

## Getting started
**Sending emails and using email widgets**

The following are the steps to get you started with creating and sending emails:
* You're using Platform Server 11.12.0 or later.
* You have activated the [technical preview](https://success.outsystems.com/Support/Enterprise_Customers/Upgrading/Technical_Preview_features) **Emails for Mobile and Reactive** in LifeTime in all environments.

1. Create an Email and add some content to it. See: [Managing emails](managing.md)
2. Create logic that renders Emails and sends them as emails to users. See: [Sending emails](sending.md)

<div class="info" markdown="1">
**Adding attachments to emails**

**Emails for Mobile and Reactive** is a technical preview feature. See: [Prerequisites](#prerequisites).
* You're using Platform Server 11.13.0 or later.
* You have activated the [technical preview](https://success.outsystems.com/Support/Enterprise_Customers/Upgrading/Technical_Preview_features) **Attachments in Mobile and Reactive emails** in LifeTime in all environments.

## Getting started

The following are the steps to get you started with creating and sending emails:

</div>
1. Create an email and add some content to it. See: [Managing emails](managing.md)
2. Create logic that sends emails to users. See: [Sending emails](sending.md)
3. Optionally, add attachments in your emails. See: [Adding email attachments](attachments.md)

For more information about emails, see the following resources:

Expand Down
1 change: 1 addition & 0 deletions toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
- topics:
- href: develop/logic/emails-reactive/managing.md
- href: develop/logic/emails-reactive/sending.md
- href: develop/logic/emails-reactive/attachments.md


- href: develop/logic/exceptions/intro.md
Expand Down

0 comments on commit 6fcae08

Please sign in to comment.