Blob to Email Attachment Delivery
On a schedule, the flow sweeps an outbound Azure Blob folder, attaches each report/invoice file to an email, routes it to the right recipient via a Dataverse distribution map, logs the delivery, and archives the file to a sent folder. Automates last-mile delivery of files produced into Blob.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow automates the last-mile delivery of files that back-end systems drop into Azure Blob Storage. Every morning it sweeps an outbound blob folder, attaches each file to an email, routes it to the right recipient using a Dataverse-backed distribution map, logs the delivery for audit, and archives the file to a sent folder so it is never re-sent.
Why it matters: reports and invoices generated by automated jobs still need to reach people. This flow closes that gap with no manual downloads, full audit logging, and tenant-portable configuration.
Ships Off (demo).
Use Case
A reporting job, billing system, or RPA process writes finished files (invoices, statements, reports) into an Azure Blob container, and those files must be emailed to the right customer or internal team. Instead of someone downloading and forwarding them, this flow delivers, logs, and archives them automatically on a daily schedule.
Flow Architecture
Daily 08:00 Recurrence
RecurrenceSweeps the outbound folder daily at 08:00 Eastern.
Initialize Trace & Config
Initialize variableMints a correlation id and binds the storage account, outbound/sent folders, default recipient, and subject prefix.
Load Distribution Map
Dataverse - ListRecordsLoads filename-prefix to recipient rows from the Blob Distribution Map table.
List & Filter Blobs
Azure Blob - ListFolder_V4 + Filter arrayLists the outbound folder and keeps files only (drops subfolders).
For Each Blob
Apply to each (concurrency 1)Derives the routing prefix (text before the first hyphen, upper-cased), resolves the recipient from the map (else default), downloads the bytes, emails the file as an attachment, logs an audit row, copies to the sent folder, and deletes the original.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_BlobStorageAccount | String | flowlibsdemostorage | Azure Storage account name used as the dataset for all blob actions. |
| flowlibs_OutboundFolderPath | String | /outbound | Source folder scanned for files to deliver. |
| flowlibs_SentFolderPath | String | /sent | Archive folder for delivered files. |
| flowlibs_DefaultRecipientEmail | String | operations@contoso.com | Fallback recipient when a prefix has no map row. |
| flowlibs_DeliveryEmailSubjectPrefix | String | Automated File Delivery: | Prepended to each delivery email subject. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Azure Blob Storage | shared_azureblob | ListFolder_V4 GetFileContentByPath_V2 CopyFile_V2 DeleteFile_V2 |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
| Microsoft Dataverse | shared_commondataserviceforapps | ListRecords CreateRecord |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Link vs attach
- For files over the mailbox attachment limit, replace the email with a SAS-link email (generate a time-limited link and send the URL).
- Batch by recipient
- Group files per recipient and send one email with multiple attachments instead of one email per file.
- Routing rules
- Add rows to the Blob Distribution Map table; no flow edit needed. Prefix matching is case-insensitive on text before the first hyphen.
- Schedule / trigger
- Change the recurrence, or convert to a blob-added trigger for near-real-time delivery.
- Failure handling
- Add a parallel failed branch on the email that logs Status = Failed and skips archive/delete so undelivered files retry next run.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Routing prefix
Derives the routing prefix from the file name.
EXPR.02Recipient resolution
Matched recipient, else default.
EXPR.03Files-only filter
Drops subfolders from the listing.
EXPR.04Archive destination
Sent-folder path for the copy.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.