Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Send email is a preview feature. This article shows how to configure plain-text messages and use an HTML document as the message body.
The send email action adds an Outlook-backed email action to a Dataflow Gen2 workflow. Start with the plain-text example to configure and verify a message, or use an HTML document as the email body. For HTML, choose an existing document or start a new one directly from the send email dialog.
To define the HTML body in M, including styled tables, value formatting, and nested content, see Advanced options for HTML email.
Prerequisites
Prepare the following items before configuring the action:
- A workspace assigned to a Fabric capacity.
- A Dataflow Gen2 item that you can edit, with send email available.
- At least one query with staging enabled, or a query configured with a data destination. An email action alone doesn't meet this requirement. A query referenced by Body must have staging disabled.
- An Outlook connection that you can authenticate and use for the action.
- Access to all connections used by the dataflow.
- A test mailbox that you control and can open to verify delivery.
- Synthetic data and a test message that contains no customer or confidential information.
For an on-demand refresh, the Dataflow Gen2 refresh documentation requires Member or higher workspace access and access to all dataflow connections. See Refresh prerequisites.
How the action fits into a refresh
The Send Email action stores an action query in the parent dataflow and executes the action through the dataflow refresh path. This walkthrough uses an on-demand refresh rather than configuring a recurring schedule.
Treat refresh execution and message delivery as separate observations. Record the refresh result, then inspect the destination mailbox. Don't infer delivery solely from a successful dataflow run.
Warning
Selecting Save & run in Dataflow Gen2 can start a refresh. Prepare the recipient, subject, and body before saving an email action. Review the existing refresh schedule and any pipeline triggers so a test message isn't sent unexpectedly. Don't retry a send until you check whether the previous message arrived.
Prepare the sample
This example uses a dedicated dataflow named Send_Email_Docs so the test doesn't modify an existing workflow. To create this sample for yourself, follow these steps:
In your Microsoft Fabric workspace, select New item, then Dataflow Gen2.
In New Dataflow Gen2 (CI/CD), enter
Send_Email_Docsin Name, and then select Create.Review the item's sensitivity label and follow your organization's classification policy for the data you use.
On Home, open the Get data dropdown list and select Blank query.
In Connect to data source, replace the blank query with the following M expression. Don't change Data gateway from (none) for this synthetic sample.
let Products = {"Notebook", "Pen", "Backpack", "Desk lamp", "Folder"}, Prices = {12, 2, 45, 30, 4}, Rows = List.Transform( {0..99}, (i) => let ProductIndex = Number.Mod(i, 5), Quantity = Number.Mod(i, 7) + 1 in { 1001 + i, Products{ProductIndex}, Quantity, Quantity * Prices{ProductIndex} } ), SampleSales = #table( type table [ OrderId = Int64.Type, Product = text, Quantity = Int64.Type, Amount = Int64.Type ], Rows ) in SampleSalesSelect Next. In Query settings, change Name from
Query1toSampleSales.Confirm that the query preview contains 100 rows, with order IDs 1001 through 1100 and the four explicitly typed columns.
Start with a static message to confirm your connection and delivery before adding query-generated text.
Configure a send email action
On Home, select Send email in the New action group.
If the dialog reports invalid or missing credentials, select Configure connection and complete the Outlook connection setup. Return to the dialog and check that the credential warning no longer appears.
Set To to your test mailbox. Use a single recipient for the first run.
Set Subject to
Send email documentation test - run 1.Set Body to the following plain text:
This is a send email documentation test using synthetic data. SampleSales contains 100 generated rows. No customer data is included.Review the configured recipient, subject, and body before proceeding.
Select OK to create the action query. This example uses the generated query
EmailAlert, whose preview result type is Action.
Leave Cc and Bcc empty for this example. The preceding screenshot shows Condition disabled at None; this example doesn't configure a condition.
Use an HTML document as the email body
You can choose an existing HTML document query or create a new document from Send email (Preview). If you're already working on a document, you can also open the email dialog from that document's output settings.
Start from the Send email dialog
On Home, select Send email in the New action group.
Open the input-mode menu beside Body and choose Select a query.
Open the Body query dropdown list. It offers existing HTML document queries, such as
HtmlAdvancedQuery, and New blank HTML body.
To reuse a document, select its query from the list. To create a document, select New blank HTML body to open the HTML document builder and set up its structure and content.
Before finishing the email configuration, confirm that Body selects the document query you intend to send. Then complete the email configuration.
Start from a document query
If you created your document with the HTML document builder, you can open the email dialog from its structural preview:
- Select the document query, such as
HtmlAdvancedQuery. - In Query settings, expand Data destination and select Send as email.
- In Send email (Preview), confirm that Body already selects the document query.
Complete the email configuration
Opening this dialog doesn't send an email. Complete the configuration before running the dataflow:
| Field or control | What to do |
|---|---|
| Configure connection | If the warning says credentials are invalid or missing, configure a usable Outlook connection and confirm that the warning clears. |
| Condition | The shown experience has None selected and the control disabled. This walkthrough doesn't configure a condition. |
| To | Enter a test mailbox you control. Use + to add another recipient entry and the delete button to remove an entry. |
| Cc and Bcc | Add recipients if needed. Leave these fields empty for the first test. |
| Subject | Enter a distinct test subject, such as HTML document email test - run 1. The document's header title doesn't set this field. |
| Body | Confirm that the intended document query is selected. This path uses the document as the body; it doesn't attach an HTML file. |
| OK | Finish configuring the email action. Review recipients and output settings before starting a refresh. |
| Cancel | Close the dialog without accepting the current changes. |
The recipient, subject, and body fields include input-mode menus. The example uses direct text for recipients and subject, with the existing HTML document query selected for Body.
Before running the action, in Queries, right-click the document query selected in Body and clear Enable staging. Its source queries can keep their existing staging settings. The dataflow must still have another query with staging enabled, or a query with a data destination.
After completing the dialog, follow Run and verify delivery. For HTML email, also inspect the received layout and content. The document's structural preview isn't a rendered email, and email apps can display content differently.
Important
HTML email doesn't render every HTML document part. Chart and MultiStat parts are omitted. Include essential information in supported text or table parts and check the received message.
Run and verify delivery
- Confirm that at least one query has staging enabled or a data destination. If Body references a query, confirm that staging is disabled on that body query.
- Confirm that you want to send the configured message to the test mailbox.
- Select Save & run to save the dataflow and start its refresh. Don't start another refresh while waiting for the result.
- Open Recent runs for the dataflow and record the refresh start time and final status.
- Open the destination mailbox and find the message by its subject.
- Compare the received sender, recipient, subject, and body with the configuration. For the plain-text example, check that the three body lines remain distinct. For an HTML document, check the headings, tables, and other supported content.
- Record how many copies arrived. Investigate unexpected duplicates before repeating the test or enabling a schedule.
For additional tests, use a distinct subject and review the recipient and expected message before each run. The following sections show how to generate the body with a named text query or an inline M expression.
Example message
The following example shows the received plain-text message body:
Generate the body with an M query
Use a named text query to read from the SampleSales sample query when you want to preview the message separately from the email action. Use the result as the body of the EmailAlert send email action query created earlier. For this plain-text example, the named query must return a text value, not a table. To send a table as part of an HTML body, use a navigation table.
Add a Blank query with the following expression:
let RowCount = Table.RowCount(SampleSales), Message = "Named query test: SampleSales contains " & Text.From(RowCount) & " rows." in MessageName the query
EmailBodyText. Confirm that its preview result is Text:Named query test: SampleSales contains 100 rows.In Queries, right-click
EmailBodyTextand clear Enable staging. Leave the source query's staging setting unchanged.
Select
EmailAlert. In Applied steps, double-click itsEmailAlertstep to reopen the Send email dialog.Open the input-mode menu beside Body and choose Select a query. Select
EmailBodyText.Set Subject to
Send email M test A - named query, confirm the recipient, and select OK.Select Save & run once. Verify the refresh result and received message.
Create the text query before opening Select a query. Choose EmailBodyText to configure the action with Body = EmailBodyText.
Important
Disable staging on the text query referenced by Body before running the action.
The dialog also identifies a staged text query before running it:
Write an M expression in the action
To read directly from the SampleSales sample query without a separate named query, edit the EmailAlert send email action query's M expression in the formula bar. This method is different from typing M syntax into the dialog's Enter a value field.
Select
EmailAlertin Queries.In the formula bar, replace only the
Bodyvalue with the following expression. Preserve the existing connection and recipient fields.Body = "Inline M test: SampleSales contains " & Text.From(Table.RowCount(SampleSales)) & " rows."This fragment belongs inside the action's message record; it isn't a complete standalone query.
In the same record, set
Subjectto"Send email M test B - inline expression".Accept the formula edit and confirm that the preview result type is Action. Preview acceptance alone doesn't confirm runtime success or delivery.
Review the recipient and expected body, then select Save & run once.
Check that the received body is
Inline M test: SampleSales contains 100 rows.
The expression produces the calculated row count in the message, not the M syntax.
Note
Enter a value is a literal-text input. M syntax entered there is stored as text rather than evaluated as an expression. Use Select a query for a named text result or edit the action's M directly for an inline expression.
The following example refresh history shows a staging-related failure followed by successful runs using the inline expression and the unstaged text query:
Troubleshoot send email
The Outlook connection can't authenticate
Record the displayed error and check which account is authenticating the connection. Confirm that the connection is available to the dataflow. Don't collect passwords, tokens, or unredacted credentials in diagnostic evidence.
A refresh succeeds but no message arrives
Check the configured recipient and the mailbox's junk folder. Compare the refresh time with the test subject, and check whether another refresh ran.
The dataflow has no query to load
A dataflow with only email actions and unstaged queries without destinations can't run. Enable staging on a query other than the query referenced by Body, or configure a data destination. Keep staging disabled on the body query.
The refresh fails
If error 101294 says the action's Body references a query enabled for staging, clear Enable staging on that referenced query, whether it returns text or an HTML document definition. Leave its source queries' staging settings unchanged. Review the message before retrying; a retry starts another dataflow run.
Open the run details and record the error text, refresh identifier, and timestamp. Include any activity or request identifier exposed by the error. Distinguish an error in the source query from an error involving the email action.
See View refresh history and monitor your dataflows.