Skip to content

Outlook 365 — Connect

Type: outlook365-connect  ·  Package: Outlook 365 v1.0.4  ·  Output: ZoanOutlookMailSession

Opens an authenticated session with Outlook 365 (Microsoft 365) through Microsoft Graph. It is the package’s starting point: every other activity (send, search, reply, move…) works on this session.

It authenticates with a Zoan Cloud Microsoft 365 OAuth connection. There are two ways to use it:

  • With body: the activities you place inside inherit the session automatically; when the block ends (also if something inside fails), the session closes by itself.
  • Without body: it returns the session as output; store it in a variable, pass it through session to the other activities and close it with Outlook 365 — Close.

When connecting:

  1. It reads the connection’s access token. If it is empty, it fails right away.
  2. If you set mailbox, the session works on that mailbox. It tries to read the mailbox’s primary address from Graph; if it can’t (for example, because the connection has no permission to read users), it uses the mailbox value as is and carries on.
  3. Without mailbox, it looks up the connection’s user (/me) and works on that user’s mailbox.

Connect does not check access to the emails yet: if permissions are missing, the error shows up in the first activity that uses them.

ParameterTypeDefaultDescription
credentialcredential—Zoan Cloud Microsoft 365 OAuth connection. Pick it in the Designer’s selector or write credential("key-name") with its key name.
ParameterTypeDefaultDescription
mailboxstring—Mailbox to work on (email or UPN, e.g. billing@example.com). Required with app-only access or for shared mailboxes. Empty = the mailbox of the connection’s user.

Activities to run inside the session. They inherit the session automatically and it closes when they finish.

Returns a ZoanOutlookMailSession only when you don’t use body; with body the activity returns nothing (the session is inherited). The session exposes two read-only properties:

PropertyTypeContent
EmailstringAddress of the connected mailbox (the primary one, if Graph could read it).
UserKeystringIdentifier used to address the mailbox in Graph: the mailbox you set or the UPN of the connection’s user.
MessageCause and fix
'credential' does not contain a valid access_token. Check the Microsoft 365 OAuth Connection in Zoan Cloud.The connection returned no token: it is pending authorization or was revoked. Open it in Zoan Cloud and check that it is Connected.
Could not resolve the signed-in user (/me). For app-only access provide the 'mailbox' parameter.Without mailbox, Graph did not return the current user: the connection is app-only or the token cannot read the profile. Set mailbox.
Could not resolve the mailbox user.Graph answered /me without a UPN or ID. Set mailbox explicitly.
Parameter 'credential' is of type 'credential' but the value was null. …The connection does not exist in the environment, or the display name was used instead of the key name.
Outlook 365 — Connect credential = credential("m365-support")
└─ body:
Outlook 365 — Get emails folder = "inbox" unreadOnly = true → output: newEmails
For each email in newEmails
└─ Outlook 365 — Reply id = email["id"] body = "We received your message and will get back to you shortly."

Without body, on a shared mailbox:

Outlook 365 — Connect credential = credential("m365-support") mailbox = "billing@example.com" → output: mbx
Outlook 365 — Get emails session = mbx subject = "Invoice" → output: invoices
Outlook 365 — Close session = mbx