Outlook 365 Mail Activities
Outlook 365 Mail Activities
Section titled “Outlook 365 Mail Activities”Version: 1.0.5 · ID: zoan-packages-outlook365 · Author: Zoan Software
The Outlook 365 package sends, searches, reads and organizes email in a Microsoft 365 mailbox through Microsoft Graph, using Zoan Cloud OAuth2 connections. It is the cloud counterpart of the desktop Outlook package: it needs neither Outlook installed nor an open Windows session, so it works the same in attended and unattended robots.
Concept 1: the connection and its permissions
Section titled “Concept 1: the connection and its permissions”The activities use a Zoan Cloud Microsoft 365 OAuth connection, referenced by its key name in Connect (credential = credential("m365-support")). Zoan Cloud stores and renews the token; the robot never sees the account password.
| Microsoft Graph permission | Used for |
|---|---|
Mail.ReadWrite | Searching, reading, downloading attachments, moving, marking, categorizing and deleting. |
Mail.Send | Sending, replying and forwarding. |
Mail.ReadWrite.Shared / Mail.Send.Shared | The same on shared mailboxes, with delegated access. |
The authentication type (delegated or app-only) is defined by the connection. With delegated access and no mailbox, the activities work on the mailbox of the user who authorized the connection; for shared mailboxes or app-only access, set mailbox in Connect.
Concept 2: the session
Section titled “Concept 2: the session”Connect opens a session (ZoanOutlookMailSession) on a mailbox:
- With
body: the activities inside inherit it, and it closes by itself when they finish. - Without
body: store it in a variable, pass it throughsessionand close it with Close.
The session uses the token that was valid when it connected, which lasts about one hour: in long processes, work in batches and connect once per batch.
Concept 3: an email is a dictionary
Section titled “Concept 3: an email is a dictionary”Get emails, Get email by ID and Move return each email as a Dictionary<string,object> with the keys id, subject, from, fromName, to, cc, receivedDateTime, preview, isRead, hasAttachments, categories, webLink, body and bodyType (details in Get emails). Read each value by key: email["subject"].
The id is the input of every other activity. It changes when the email is moved to another folder: do your work on the email before moving it, or use the id returned by Move.
Activities
Section titled “Activities”| Activity | Type | Output | Description |
|---|---|---|---|
| Outlook 365 — Connect | outlook365-connect | ZoanOutlookMailSession | Opens an authenticated Outlook 365 session through Microsoft Graph |
| Outlook 365 — Send | outlook365-send | — | Sends an email from the session’s mailbox |
| Outlook 365 — Reply | outlook365-reply | — | Replies to an existing email, keeping the thread |
| Outlook 365 — Forward | outlook365-forward | — | Forwards an email to other recipients |
| Outlook 365 — Get emails | outlook365-get-emails | List<Dictionary<string,object>> | Searches the mailbox or a folder by subject, text, filter or unread status |
| Outlook 365 — Get email by ID | outlook365-get-email | Dictionary<string,object> | Gets a full email by its ID, including the body |
| Outlook 365 — Download attachments | outlook365-download-attachments | List<string> | Downloads an email’s attachments to a folder |
| Outlook 365 — Move | outlook365-move | Dictionary<string,object> | Moves an email to another folder |
| Outlook 365 — Mark read/unread | outlook365-mark-read | — | Marks an email as read or unread |
| Outlook 365 — Set categories | outlook365-set-categories | — | Sets an email’s categories (replacing the existing ones) |
| Outlook 365 — Delete | outlook365-delete | — | Deletes an email |
| Outlook 365 — Close | outlook365-close | — | Closes an Outlook 365 session |
Full process example
Section titled “Full process example”Outlook 365 — Connect credential = credential("m365-invoices") └─ body: Outlook 365 — Get emails folder = "inbox" subject = "Invoice" unreadOnly = true → output: pending For each email in pending └─ Outlook 365 — Download attachments id = email["id"] folder = "C:\invoices\inbox" Outlook 365 — Reply id = email["id"] body = "We received your invoice and will record it in the next few days." Outlook 365 — Move id = email["id"] destination = "archive"