TABLE OF CONTENTS
- Mailbox Monitoring and Email Processing
- Configuring Mailbox Monitoring
- Email Processing Workflow
- Pre-Processor Script Examples
- Troubleshooting
- Further Support
Mailbox Monitoring and Email Processing
ManagementStudio can monitor a mailbox for incoming emails. This capability supports both replies to system-generated emails and new emails sent directly to the system for further action.
Email messages can be triaged as they are processed. Actions include ignoring certain emails, raising defects, or attaching emails to existing records. For example, out-of-office replies can be ignored or linked to a user’s record for a migration engineer to reference.
Configuring Mailbox Monitoring
Polling Frequency
The frequency with which mailboxes are checked is controlled by the EmailTasks:ReceiveEveryXMin setting in the appSettings.json file.
- Minimum value: 2 minutes
- Recommended value: 10 minutes
Email Settings Configuration
Access the email monitoring configuration at:
Administration → Project Settings → Email & Keywords
Configure the following fields:
| Setting | Description |
|---|---|
Email From Address (1) | The address shown in the ‘From’ field of emails sent from ManagementStudio. |
Email From Display Name (2) | The sender display name for emails sent from ManagementStudio. |
Enable Tracking (3) | Adds a tracking token to each outgoing email. Allows ManagementStudio to recognise and link replies to the original item (e.g., app, user, or device record). |
Monitor a Mailbox / Enabled (4) (5) | Enable to start monitoring the specified mailbox. |
Create Defects for emails...(6) | Enable to automatically raise a defect for emails that cannot be linked to an app, user, or device. |
Pre-Processor Script (7) | The ID of a custom PowerShell script for custom triage logic. Only one script can be assigned. |
Shared Mailbox Alias (8) | Enter the alias of a shared mailbox, if applicable, to process only emails from that mailbox. |
Mail Server Details (9) | Specify the mail server address and port. SSL settings can usually remain on 'Auto', but may be set manually if required. |
Mail Authentication (10) | Enter the username and password for authenticating with the mail server. Or enter the Azure Tenant Id and corresponding Azure client Id. |
Troubleshooting (11) | Fields include: - Last Error: Most recent SMTP error.- Last Message Id: The ID of the last processed message.- Last Message Date: Last email processed.- To reprocess emails: clear both the last message ID and date fields. |

Email Processing Workflow
Email Event Handling
After an email is processed—either attached to a record or raised as a defect—the Email Received event is triggered. Emails ignored during processing are not included.
Use this event to automate further actions, such as moving new defects to a specific workflow or assigning them to designated users.
Pre-Processor Script
A PowerShell pre-processor script can be defined for advanced triage logic. The script is executed after the email is read but before actions are committed, allowing custom handling or routing.
- Define the script in:
Administration → PS Scripts, Emails, Buttons - Enter the script’s ID into the
Pre-Processor Scriptfield in Email Settings.
Email Data Provided to Pre-Processor
The PowerShell script receives an array of email objects in ScriptArgs.EventData. Fields available:
| Field | Type | Description |
|---|---|---|
EmailId | int | Unique email identifier; use when returning updates. |
Ignore | bool | Set to true to halt further processing of this email. |
IsNewDefect | bool | Set to true to raise a defect and attach the email. |
ProjectId | int | Associated Project ID. |
ModuleId | int | Module to which the email will be attached. |
InstanceId | int | Instance within the module for linkage. |
MessageId | string | Mail server message identifier. |
To | string | Recipient email address(es). |
From | string | Sender email address. |
Subject | string | Email subject. |
ContentAsText | string | Email content as plain text (HTML tags removed). |
ContentAsHtml | string | Email content as HTML (included only if "HtmlContent" added to Args1). |
Note: ManagementStudio will try to match incoming replies to sent messages and attach them to the originating item (user, app, etc.).
Returning Updates to ManagementStudio
The script must return a hashtable of updates for each email. Only EmailId is required; all other fields are optional depending on the desired processing logic.
Example Email Module IDs
| Module | ModuleId |
|---|---|
| Applications | 1 |
| UserMigrations | 2 |
| Devices | 3 |
| Mailboxes | 4 |
| BespokeModule | 5 |
| DeploymentUnits | 6 |
| Defects | 8 |
| Contacts | 12 |
| Tasks | 14 |
- Module and Instance IDs can be set by your script, or supplied by the system when matching a reply to a previous message.
Pre-Processor Script Examples
Example 1: Out-of-Office Auto-ignore
This script ignores emails which are likely out-of-office replies.
$updatesHash = @{}
foreach($email in $ScriptArgs.EventData) {
$updatesHash.Add($email.EmailId, @{ EmailId = $email.EmailId; Ignore = $email.Ignore; IsNewDefect = $email.IsNewDefect; InstanceId = $email.InstanceId; ModuleId = $email.ModuleId; })
}
foreach($email in $ScriptArgs.EventData) {
if($email.ContentAsText -match "I.*out.*of.*office/ig") {
$updatesHash[$email.EmailId].Ignore = $true
}
}
$updatesHash.Values
Example 2: Attach Email to App by AppId in Subject
This script looks for an AppId:1234 pattern in the email subject and links the email accordingly.
$updatesHash = @{}
foreach($email in $ScriptArgs.EventData) {
$updatesHash.Add($email.EmailId, @{ EmailId = $email.EmailId; Ignore = $email.Ignore; IsNewDefect = $email.IsNewDefect; InstanceId = $email.InstanceId; ModuleId = $email.ModuleId; })
}
foreach($email in $ScriptArgs.EventData) {
$subject = $email.Subject
$subject = $subject.Replace(' ', '').ToLower()
if($subject -match "appid:") {
$idStartsAtIdx = $subject.IndexOf("appid:") + 6
$subject = $subject.Substring($idStartsAtIdx)
if($subject -match "\d+") {
$appId = $Matches[0]
$updatesHash[$email.EmailId].Ignore = $false
$updatesHash[$email.EmailId].IsNewDefect = $false
$updatesHash[$email.EmailId].InstanceId = $appId
$updatesHash[$email.EmailId].ModuleId = 1
} else {
$updatesHash[$email.EmailId].Ignore = $false
$updatesHash[$email.EmailId].IsNewDefect = $true
$updatesHash[$email.EmailId].InstanceId = 0
$updatesHash[$email.EmailId].ModuleId = 0
}
}
}
$updatesHash.Values
Troubleshooting
- Last Error: Review in Email Settings for SMTP server errors.
- Last Message Id/Date: Indicates what message was last processed; clear these fields to force reprocessing.
Further Support
For additional assistance, visit the ManagementStudio Service Desk to search the knowledge base or create a new support ticket.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article