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.

Creating the App Registration in Entra ID and obtaining folder IDs is the same for both crons, so it is not repeated here. See the article MS Graph – cron configuration.

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.
On 5.7 and 5.17, meeting invitations and automatic replies are not filtered out. A meeting invitation or an "out of office" reply will create a case just like regular mail. If this bothers the customer, filter these messages out with a rule directly in the mailbox. In addition, errors in the JSON (a typo in a folder or template ID) only show up when the cron runs, in the run summary.

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 (runSummary setting),
  • e-mail to those responsible for a mailbox – each recipient only gets errors from their own mailboxes (errorEmailAddresses setting 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

  1. Open the MsGraphCreateProcessesFromMailCron2 cron and review the pre-filled settings against the parameter tables below. Pay particular attention to runSummary – where the summary e-mails will be sent.
  2. Deactivate the original cron MsGraphCreateProcessesFromMailCron.
  3. Activate MsGraphCreateProcessesFromMailCron2.
  4. After the first run, check the summary record in the log.
The order matters. As long as the original cron is active, V2 cannot be activated.

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:

  1. convert its settings using sys.msGraphConvertParamsForCron2(CLONE_ID),
  2. clone the V2 cron and paste the result into it,
  3. 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 items[].config

errorEmailAddress (single address)

errorEmailAddresses (list of addresses)

ignoreAttachments

ignoreAllAttachments

–

new runSummary block. If the instance has cron error addresses configured, it is filled with them and the summary e-mail is enabled.

–

new messageClass block with the default filter (5.19 only)

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" }
            }
        }
    ]
}
Add another mailbox as another item in the 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

amountOfEmailByRun

No

100

How many e-mails are retrieved from each mailbox per run. If set to 0 or omitted, 100 is used.

runSummary

No

see below

Run summary in the log and by e-mail.

items

Yes

–

List of mailboxes. If empty, the cron has nothing to process.

runSummary – run summary

Parameter

Required

Default

What it does

log

No

true

Writes the summary to the log: totals and, for each failed e-mail, the mailbox, subject, sender and error.

sendEmail

No

false in the form

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 false.

emailAddresses

Conditional

[]

Where the summary is sent. On 5.19 it is required when sendEmail is enabled, and the field only appears once it is enabled. If left empty, the summary goes to the cron error addresses from the instance configuration.

Caution on 5.7 and 5.17 (JSON): if you delete the 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

emailAddress

Yes

–

Mailbox address. On 5.19 it is used to name the item in the list of mailboxes.

tenantId

Yes

–

Tenant (directory) ID in Microsoft Entra ID.

clientId

Yes

–

Application (client) ID from the App Registration.

clientSecret

Conditional

–

Required with type: "secret". Instead of a plain-text secret, we recommend a vault reference in the form {{vault:name}}.

type

Yes

secret

secret or dedicated. Any other value is an error.

scope

No

[]

Optional permission scopes.

items[].folders – folders

Parameter

Required

What it does

in.id

Yes

Folder from which e-mails are retrieved.

out.id

Yes

Folder to which e-mails are moved after processing.

items[].process – what case is created

Parameter

Required

What it does

user_id

Yes

User under whom the case is created.

tproc_id

Yes

Template from which the case is created.

header_id

Yes

Header the case belongs to.

holderData

–

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

errorEmailAddresses

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 runSummary.

setEmailProcessedOnError

No

true

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.

ignoreAllAttachments

No

false

No attachments are uploaded to the case.

ignoreSpecificAttachments

No

false

Skips only attachments with extensions listed in ignoredAttachmentTypes. Cannot be combined with ignoreAllAttachments.

ignoredAttachmentTypes

Conditional

[]

Extensions to skip, e.g. .p7s (electronic signature). With or without the dot, case-insensitive. When ignoreSpecificAttachments is enabled, it must contain at least one extension.

ignoreInlineAttachments

No

false

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.

attachEmailAsPdf

No

false

Saves the e-mail itself to the case as a PDF Mail_<date>_<sender>.pdf in the application language. Images are replaced with a text note and attachment names are listed, so the PDF stays small. If the PDF cannot be created, this is only logged and the e-mail is processed further.

ignoreAttachmentErrors

No

true

Errors while processing attachments do not stop processing of the e-mail.

ignoreVariablesUpdateAndUseDataHolder

No

true

Case variables are not filled directly; data from the e-mail is stored in holderData.

useEmailObjectInDataHolder

No

false

The entire e-mail object is stored in holderData.

Signature images vs. extensions: 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

enabled

No

true

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.

allowedPrefixes

No

["IPM.Note"]

Message types that are processed. IPM.Note is regular mail. Meeting invitations (IPM.Schedule.*) and delivery reports (REPORT.*) are thereby excluded.

ignoredClasses

No

["IPM.Note.Rules.OofTemplate.Microsoft"]

Specific types that are rejected even if they match an allowed type. The default value is the "out of office" automatic reply.

An empty list does not mean "allow nothing". An empty 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

from.emailAddress.address

sender

subject

subject

body.content

e-mail body (HTML)

toRecipients

recipients

attachmentErrors

special key – list of attachment errors as JSON text

For data that may not always be present in the e-mail, use "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.

You can safely leave the 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.

Frantisek Brych Updated by Frantisek Brych

MS Graph - cron configuration

MS Graph - preparing the mailbox

Contact

Syca (opens in a new tab)

Powered by HelpDocs (opens in a new tab)