What Is An Inbound Email Action?
An email is a form of an integration.
You can use this email integration to do things like create and update any type of record in ServiceNow.
You can extract things like the subject, email body, etc. and set those values to the ServiceNow form.
Inbound email action in ServiceNow is a feature that allows users to create automated workflows or scripts that can be triggered by incoming email messages. With this feature, ServiceNow can monitor a designated email account, and when an email arrives, it can be parsed and processed according to predefined rules.
Inbound email actions can be configured to perform various actions based on the content of the email, such as creating a new record, updating an existing record, assigning a task, sending an email notification, or triggering a workflow. This feature can be used to automate IT service management processes, such as incident management, change management, or request fulfillment.
Inbound email actions in ServiceNow are highly customizable and can be configured using the ServiceNow Workflow Designer or scripting. They also support a variety of email protocols and formats, including POP3, IMAP, and SMTP, as well as attachments and HTML formatting.
To find your Inbound Actions, go to System Policy > Email > Inbound Actions.
What Does The Inbound Action Script Look Like?
When you create an inbound email action, you have access to the email object in ServiceNow.
Let’s look at the out of box “Create Incident” Inbound Action to see an example.
// Note: current.opened_by is already set to the first UserID that matches the From: email address
current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high") {
current.impact = 1;
current.urgency = 1;
}
}
if (current.canCreate())
current.insert();
When this is configured properly, and you send an email to ServiceNow, if this condition returns true, then you will process this script and it will create an incident.
You can do this for any application or table in your system.
What Is The Email Object?
In ServiceNow, the email object is a JavaScript API that provides methods for sending email notifications and managing email messages within ServiceNow. The email object can be used to send email notifications to users or groups, or to interact with incoming emails and their attachments.
Here are some examples of how to use the email object in ServiceNow:
- Sending an email notification:
To send an email notification using the email object, you can use the send()
method. For example, the following code sends an email notification to the specified email address:
var email = new GlideEmailOutbound();
email.setSubject('New Incident Created');
email.setBody('A new incident has been created in ServiceNow');
email.addRecipient('example@email.com');
email.send();
- Retrieving incoming emails:
To retrieve incoming emails using the email object, you can use the GlideEmailInbound
object. For example, the following code retrieves the most recent email from the specified email account:
var email = new GlideEmailInbound().getMessages(1)[0];
- Managing email attachments:
To manage email attachments using the email object, you can use the GlideSysAttachment
object. For example, the following code retrieves the attachment from the most recent email in the specified email account and saves it as an attachment in ServiceNow:
var email = new GlideEmailInbound().getMessages(1)[0];
var attachment = new GlideSysAttachment();
attachment.write(email.getAttachment(0).getContentStream(), 'incident_attachment.txt', 'incident_sys_id');
The email object in ServiceNow is a powerful tool for managing email notifications and messages within the platform, and can be used to automate workflows and streamline IT service management processes.
Tips And Tricks To Remember When Creating Inbound Actions
Here are some tips and tricks to know when creating inbound email actions in ServiceNow:
- Define your requirements: Before creating an inbound email action, it’s important to define your requirements and understand what you want to achieve. This will help you to select the appropriate action type, configure the necessary fields, and ensure that the inbound email action meets your business needs.
- Test thoroughly: Always test your inbound email actions thoroughly before deploying them in a production environment. This will help you to identify any issues or errors and make any necessary adjustments to ensure that the inbound email action works correctly.
- Use conditions and filters: Use conditions and filters to ensure that the inbound email action is triggered only when necessary. This can help to reduce the number of unnecessary email notifications or actions and improve the overall efficiency of your IT service management processes.
- Use default values: Use default values for fields that are not included in the incoming email, if applicable. This can help to ensure that the record created by the inbound email action includes all the necessary information, even if it is not included in the email.
- Consider security: Inbound email actions can represent a security risk if not properly configured. Ensure that the email address used to trigger the inbound email action is secure, and consider using encryption or other security measures to protect sensitive information.
- Leverage the email object API: The email object API in ServiceNow provides a powerful set of tools for managing email notifications and messages within the platform. Leverage this API to automate workflows and streamline your IT service management processes.
By following these tips and tricks, you can create effective and efficient inbound email actions in ServiceNow that meet your business needs and enhance your IT service management processes.