MS Graph v2 (from v5.7.102)
The MsGraphCreateProcessesFromMailCron2 cron (hereinafter V2) creates cases from e-mails retrieved via Microsoft Graph. It is the successor to the MsGraphCreateProcessesFromMailCron cron (hereinafter the original cron). The original cron remains unchanged and keeps running – switching to V2 is a deliberate step you take when you decide to.
This article is written for consultants: what V2 brings, how to switch to it, and what each parameter means.
Availability
|
TAS version |
Available from |
How it is configured |
Message type filter and header mapping |
|
5.7 |
5.7.102 |
manual JSON editing |
no |
|
5.17 |
5.17.16 |
manual JSON editing |
no |
|
5.19 |
5.19.5 |
form with validation |
yes |
The core is the same on all versions. On 5.19, in addition:
- settings are entered in a form that catches errors as soon as you save,
- the user, template and header are selected from a list instead of typing IDs,
- fields that make no sense in the current context are hidden (e.g. attachment extensions only appear once their filter is enabled),
- the message type filter (
messageClass) and header mapping (headerMapping) are available.
What is different in V2
A single error no longer brings down the whole run
This is the main reason V2 was created. With the original cron, one unavailable mailbox or one broken e-mail was enough to stop the rest of that run from being processed. V2 processes each mailbox and each e-mail independently. It records the problem and moves on.
Summary after every run
After every run, one summary record is added to the log: how many e-mails were retrieved, processed, skipped and failed. For each failed e-mail it lists the mailbox, subject, sender and reason. You no longer need to go through the whole log.
If there was at least one error in the run, the following can also be sent:
- summary e-mail – one message for the whole run (
runSummarysetting), - e-mail to those responsible for a mailbox – each recipient only gets errors from their own mailboxes (
errorEmailAddressessetting on the mailbox). If their mailboxes went through without errors, they receive nothing.
A successful run sends no e-mail.
Settings check before connecting
Before V2 connects to a mailbox, it checks its settings: credentials, folder IDs, numeric process IDs and conflicting attachment switches.
Protection against double processing
Only one of the crons MsGraphCreateProcessesFromMailCron and MsGraphCreateProcessesFromMailCron2 (including their clones) may be active at a time. Attempting to save the other one as active ends with an error. If this is bypassed by modifying the database, V2 detects at startup that the original cron is running, skips itself and logs the reason.
Other new features
- An e-mail for which a case could not be created stays unread in the input folder and is retried in the next run.
- Ignoring signature images – logos and banners don't have to be saved as case documents.
- E-mail as PDF – the message itself can be saved to the case as a PDF.
- Message type filter (5.19 only) – meeting invitations, delivery reports and "out of office" replies do not create a case.
- Header mapping (5.19 only) – a custom e-mail header can be saved into a variable.
Switching from the original cron
When you upgrade to a version with V2, the V2 cron is created automatically and pre-filled based on the original cron: mailboxes, credentials, mapping, schedule and timeout. However, it is created as inactive, so nothing starts on its own and nothing is processed twice. The original cron remains unchanged and keeps running.
Switchover procedure
- Open the
MsGraphCreateProcessesFromMailCron2cron and review the pre-filled settings against the parameter tables below. Pay particular attention torunSummary– where the summary e-mails will be sent. - Deactivate the original cron
MsGraphCreateProcessesFromMailCron. - Activate
MsGraphCreateProcessesFromMailCron2. - After the first run, check the summary record in the log.
How to verify the converted settings
Run the following in the service console:
sys.msGraphConvertParamsForCron2()
The function returns the original cron's settings converted into the V2 structure without changing anything. Use it for comparison or to copy into V2. To convert a specific cron (e.g. a clone), pass its ID:
sys.msGraphConvertParamsForCron2(42)
Clones of the original cron
If you have cloned the original cron for multiple configurations, the migration does not convert the clones. It only lists them in the update log. For each clone:
- convert its settings using
sys.msGraphConvertParamsForCron2(CLONE_ID), - clone the V2 cron and paste the result into it,
- deactivate the clone of the original cron and activate the V2 clone.
What changes during conversion
|
Original cron |
V2 |
|
switches directly on the mailbox |
moved to |
|
|
|
|
|
|
|
– |
new |
|
– |
new |
Configuration example
One mailbox for invoices. The responsible accountant receives errors from her mailbox, support receives the summary of the whole run, and signature images are not saved.
{
"amountOfEmailByRun": 100,
"runSummary": {
"log": true,
"sendEmail": true,
"emailAddresses": ["podpora@firma.cz"]
},
"items": [
{
"auth": {
"type": "secret",
"emailAddress": "faktury@firma.cz",
"tenantId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000",
"clientSecret": "{{vault:msgraph-faktury}}"
},
"folders": {
"in": { "id": "INPUT_FOLDER_ID" },
"out": { "id": "OUTPUT_FOLDER_ID" }
},
"process": {
"user_id": 1,
"tproc_id": 25,
"header_id": 3
},
"config": {
"errorEmailAddresses": ["ucetni@firma.cz"],
"ignoreInlineAttachments": true
},
"mapping": {
"sender": { "value": "from.emailAddress.address", "option": "optional" },
"mailSubject": { "value": "subject", "option": "optional" },
"mailBody": { "value": "body.content", "option": "optional" }
}
}
]
}
items array. On 5.19, use the button in the form to copy an item and change only what differs.Parameters
The Required column:
- Yes – if not filled in, the mailbox is not processed and the reason appears in the summary,
- No – can be omitted, the default value is used,
- Conditional – required only in the situation described for the parameter.
For optional parameters, deleting the key is the same as setting the default value. The form on 5.19 keeps some keys even with an empty value – that is fine.
Top level
|
Parameter |
Required |
Default |
What it does |
|
|
No |
|
How many e-mails are retrieved from each mailbox per run. If set to |
|
|
No |
see below |
Run summary in the log and by e-mail. |
|
|
Yes |
– |
List of mailboxes. If empty, the cron has nothing to process. |
runSummary – run summary
|
Parameter |
Required |
Default |
What it does |
|
|
No |
|
Writes the summary to the log: totals and, for each failed e-mail, the mailbox, subject, sender and error. |
|
|
No |
|
Sends the summary by e-mail only if there was at least one error in the run. One message for the whole run. The summary is not sent only when this is explicitly set to |
|
|
Conditional |
|
Where the summary is sent. On 5.19 it is required when |
sendEmail key, the summary is sent. If you leave emailAddresses empty, it goes to the cron error addresses from the instance configuration. If you don't want the summary e-mail, explicitly set "sendEmail": false.items[].auth – mailbox sign-in
|
Parameter |
Required |
Default |
What it does |
|
|
Yes |
– |
Mailbox address. On 5.19 it is used to name the item in the list of mailboxes. |
|
|
Yes |
– |
Tenant (directory) ID in Microsoft Entra ID. |
|
|
Yes |
– |
Application (client) ID from the App Registration. |
|
|
Conditional |
– |
Required with |
|
|
Yes |
|
|
|
|
No |
|
Optional permission scopes. |
items[].folders – folders
|
Parameter |
Required |
What it does |
|
|
Yes |
Folder from which e-mails are retrieved. |
|
|
Yes |
Folder to which e-mails are moved after processing. |
items[].process – what case is created
|
Parameter |
Required |
What it does |
|
|
Yes |
User under whom the case is created. |
|
|
Yes |
Template from which the case is created. |
|
|
Yes |
Header the case belongs to. |
|
|
– |
Read-only. Filled at runtime according to the mapping; anything you write here is ignored. |
user_id, tproc_id and header_id must be numbers. On 5.19 you select them from a list, so they cannot be entered incorrectly.
items[].config – mailbox behavior
|
Parameter |
Required |
Default |
What it does |
|
|
No |
|
People responsible for this mailbox. After a run with errors, each address receives an e-mail containing only the errors from its own mailboxes. Works independently of |
|
|
No |
|
What to do with the e-mail when the case was created but its workflow did not start. Enabled: the e-mail is marked as read and moved to the output folder. Disabled: it stays unread and every subsequent run creates another faulty case from it. |
|
|
No |
|
No attachments are uploaded to the case. |
|
|
No |
|
Skips only attachments with extensions listed in |
|
|
Conditional |
|
Extensions to skip, e.g. |
|
|
No |
|
Does not save images embedded in the message body (signature logos, banners). They remain visible in the e-mail body. Regular attachments (an invoice as PDF or JPG) are not affected. |
|
|
No |
|
Saves the e-mail itself to the case as a PDF |
|
|
No |
|
Errors while processing attachments do not stop processing of the e-mail. |
|
|
No |
|
Case variables are not filled directly; data from the e-mail is stored in |
|
|
No |
|
The entire e-mail object is stored in |
ignoredAttachmentTypes with .jpg skips every JPG, including a scanned invoice. For signature logos, use ignoreInlineAttachments instead, which lets regular attachments through.attachEmailAsPdf noticeably extends the cron run time, because a PDF is generated for every e-mail. Enable it only where the customer really needs it.items[].messageClass – message type filter (5.19 only)
|
Parameter |
Required |
Default |
What it does |
|
|
No |
|
A case is created only from allowed message types. Other messages are logged and moved to the output folder. An e-mail whose type cannot be determined is always processed. |
|
|
No |
|
Message types that are processed. |
|
|
No |
|
Specific types that are rejected even if they match an allowed type. The default value is the "out of office" automatic reply. |
allowedPrefixes or ignoredClasses behaves like the default list. If you want to process absolutely everything, turn off the filter with enabled: false.items[].mapping – what is stored in variables
The key is the name of the process variable; the value is a path in the e-mail, or an object { "value": …, "option": …, "isConstant": … }.
|
Path |
Meaning |
|
|
sender |
|
|
subject |
|
|
e-mail body (HTML) |
|
|
recipients |
|
|
special key – list of attachment errors as JSON text |
"option": "optional". A missing value is then stored as empty and the e-mail processing does not fail because of it."sender": { "value": "from.emailAddress.address", "option": "optional" }items[].headerMapping – headers into variables (5.19 only)
Optional. The key is the variable name; the value internetMessageHeaders loads the header with the same name as the variable.
"headerMapping": {
"X-Header-Company": "internetMessageHeaders"
}
The example fills the X-Header-Company variable from the X-Header-Company header.
messageClass and headerMapping parameters in the JSON on 5.7 and 5.17. They won't break anything, they are simply not used.Troubleshooting
The V2 cron cannot be activated
Most likely the original cron MsGraphCreateProcessesFromMailCron or one of its clones is active. Only one of them may be active. Deactivate the original cron first.
The cron runs but does not create cases
Find the summary record of the last run in the log. If there is an error in the mailbox settings, the summary states exactly what it is, for example auth.clientSecret is missing for type 'secret' or folders.in.id is missing. Another possibility: the cron detected that the original cron is active, skipped itself and logged it.
The summary e-mail is not arriving
The summary e-mail is sent only after a run with at least one error. A successful run sends no e-mail. Also check that runSummary.sendEmail is not false and that runSummary.emailAddresses contains the correct address, or that the instance has cron error addresses configured.
The summary e-mail goes to an address nobody monitors
When runSummary.emailAddresses is empty, the summary goes to the cron error addresses from the instance configuration. Add your own addresses, or turn off the summary with "sendEmail": false.
Meeting invitations and "out of office" replies create cases
On 5.19, check that messageClass.enabled is turned on for the mailbox. On 5.7 and 5.17 the filter is not available – filter these messages out with a rule in the mailbox.
Attachment settings cannot be saved
ignoreAllAttachments and ignoreSpecificAttachments cannot be enabled at the same time: either all attachments are skipped, or only selected types. When ignoreSpecificAttachments is enabled, ignoredAttachmentTypes must contain at least one extension.
A single e-mail creates a new faulty case on every run
The mailbox has setEmailProcessedOnError disabled, so an e-mail with a failed workflow stays in the input folder. Enable it so that such an e-mail is moved to the output folder after the error.
The cron runs slowly
The most common cause is attachEmailAsPdf being enabled, because a PDF is generated for every e-mail. The second is a high value of amountOfEmailByRun.
Updated
by Frantisek Brych