Zoomed Image

Mail Connections and Routes

Configuration Guide

Deployment and Administration

Mail Connections and Routes

xAssets can read email from a Microsoft 365 mailbox and pass each message to a transformation. A mail connection names the mailbox. A mail route names the transformation that receives each message. The service desk mailbox and emailed delivery notes for purchase orders both work this way.

Reading mail is separate from sending it. xAssets sends email through SMTP (see Email Configuration).

Both lists are under Admin > Mail. Administrators and Configuration Users can open them.

Menu Shows
Mail Connections The mailboxes xAssets reads mail from, with Last Fetch and Last Error
Mail Routes Which transformation receives each message
Mail Due for Removal The handled mail that the next run of Mail Retention would remove

The Mail Connections list, with the New Mail Connection, Check Mail Connection and Fetch Mail Now actions above it

Requirements

  • A Microsoft 365 mailbox. A shared mailbox needs no license.
  • An app registration in Microsoft Entra ID with a client secret. Give it no Microsoft Graph mail permission in Entra. A mail permission granted there opens every mailbox in the tenant.
  • An Exchange Online role assignment that gives the app Application Mail.ReadWrite on that mailbox only, through a management scope. Use Application Mail.Read when After Fetch is LEAVE. The app does not need a send role.
  • Outbound HTTPS from the xAssets application server to login.microsoftonline.com and graph.microsoft.com.
  • The xAssets Batch Service running.

An Exchange administrator creates the management scope and the role assignment in Exchange Online PowerShell. A new role assignment can take up to 2 hours to apply.

Setting Up a Connection

  1. Create a credential pack (gear icon > Credentials > New), for example named Mailbox. Put the Directory (tenant) ID in Domain Name, the Application (client) ID in Username and the client secret Value in Password. Use a separate app registration and pack for mail. Do not reuse the pack of an Azure integration.
  2. Open Admin > Mail > Mail Connections and click New Mail Connection.
  3. Fill in the fields:
Field Value
Connection Name A name for the mailbox
Provider GRAPH. Blank means GRAPH. No other provider is supported
Credential Pack The pack from step 1
Mailbox Address The mailbox, such as servicedesk@example.com
Folder The folder to read. Blank means Inbox
After Fetch MOVE moves each message read to the processed folder (the default). LEAVE leaves it where it is. DELETE moves it to Deleted Items
Processed Folder The folder for MOVE. Blank means xAssets Processed. The first fetch creates it
May Send Not used. Replies are sent through SMTP
Enabled Yes for a connection that Fetch Mail Now and the schedule read
  1. Select the connection and click Check Mail Connection. It signs in, reads the folder's message counts and the date of the newest message, and checks the processed folder. It keeps and changes nothing. Each line of the result starts with OK, FAIL or NOTE.
  2. Click Fetch Mail Now to read the new mail. To read mail on a schedule, schedule the Mail - Fetch transformation in Admin > Transformations > Scheduled Transformations. With no parameters it reads every enabled connection.

The first fetch of a connection reads mail received in the last 7 days. Older mail is never read. Later fetches read only new mail. A fetch reads up to 200 messages, and the next fetch carries on from there.

Two settings in the Mail class of Admin > Settings limit what is kept from each message:

Setting Code Shipped value
Mail sources: largest message kept whole, in MB MailMaxMessageMB 25
Mail sources: most attachments kept from one message MailMaxAttachments 20

Routing Mail

At the end of each fetch, every new message is matched against the enabled routes. The route with the lowest Priority that matches takes the message. A message that no route takes stays unrouted.

  1. Open Admin > Mail > Mail Routes and click New Mail Route.
  2. Fill in the fields:
Field Value
Route Name A name for the route
Priority A number. The lowest matching number wins
Connection The mail connection. Blank matches mail from any connection
To Contains, From Contains, Subject Contains Text the address or subject must contain. Case does not matter. Blank matches anything
Require Authenticated Yes takes only mail from inside your organization, or mail that passed DMARC. Use it for any route whose transformation changes data
Include Machine Mail Yes also takes mail that xAssets marks as sent by a machine. No leaves it unrouted
Transform The name of the transformation that receives the message
Enabled Yes to use the route
  1. To route mail that no route took, after you add or change a route, click Route Unrouted Mail.

A route that names a transformation that does not exist is skipped, and the fetch reports it.

The receiving transformation uses the source type Mail Routed to this Transformation. Each run takes the messages routed to it and marks each one handled or failed. See Transformation Data Sources.

Removing Old Mail

The Mail Retention transformation removes handled mail and its attachments. It keeps them for the days in Mail sources: days to keep handled messages (MailRetentionDays, shipped value 90). It comes with a daily schedule, switched off. Switch it on in Admin > Transformations > Scheduled Transformations. Check Admin > Mail > Mail Due for Removal first to see what it would remove.