---
title: Creating Automatically a Ticket when Receiving an E-mail  
slug: helium-en/creating-automatically-a-ticket-when-receiving-an-e-mail
description: Learn how to automatically generate tickets from emails with this comprehensive guide. Explore step-by-step instructions on configuring an email account for IMAP access and enabling batch routines. Discover the procedure for creating ticket templates, set
createdAt: 2021-10-21T16:29:33.000Z
---

This functionality allows to <font color="#2166ae">**automatically create tickets** </font>when an e-mail message is sent to a certain address. In this context, the solution constantly monitors the presence of messages in the mailbox, and if some message has the status of not read, this will be used to register a new ticket.

:::BlockQuote
<u>**For example**</u>, a user should request a service by sending a message to [service@company.com](mailto\:service@company.com).&#x20;
Upon receipt of the e-mail, the functionality identifies that a message exists and registers a ticket automatically.
:::

:::hint{type="success"}
✅ <u>**Rule**</u>**:** It is important to highlight that after the ticket registration, the e-mail is marked as read.
:::

## Before getting started

To create a ticket through the receiving of an e-mail, it is necessary to:

- [x] Configure an e-mail account to previously allow the access via IMAP.&#x20;
- [x] Configure the instance to use batch routines since e-mail verification is a scheduled task.

## Procedure

**Step 1 - Creating ticket template**

Access the functionality through the main menu `System > Automatic actions > Incident/Request/Procedure Actions`         (see [Registering Automatic Actions of Incident/Request/Procedure](docId\:uqSdsjGzJTuf4gKt4I9gl)).

**Step 2 - Set up access to the email box**

Create the email automatic action by accessing the main menu `System > Settings > Automatic Action Setting Via E-mail. `This register is used to trigger the reading and register of requests (see [Creating Automatic Action via E-mail](docId\:b3GQyq32aOAiK9TB4iN3A))&#x20;

**Step 3 - Create a verification routine (batch)**

Create a batch routine, by accessing the main menu `System > Batch Processing` (see [Batch Processing](docId\:EBxwlTJb4GRCw2cAqiJCQ)), of "**Java Class**" type with the following content:

```java
 br.com.4biz.citcorpore.quartz.job.JobConfiguracaoAberturaAutomaticaViaEmail
```

:::hint{type="info"}
🖊 <u>**Note**</u>**:&#x20;**&#x49;t is possible to read the title of the e-mail sent. It would be stored in the "**Subject"&#x20;**&#x66;ield of the *reademaildatarequest&#x20;*&#x74;able.
:::

In addition, if there is a need to retrieve other information contained in the e-mail fields, as recipients marked as a copy (CC) or hidden copy (BCC) use the Rhino script below:

```java
var importNames = JavaImporter(); importNames.importPackage(Packages.br.com.citframework.util); var print = java.lang.System.out; var readEmailDataDTO = serviceRequest.getReadEmailDataDTO(); if (readEmailDataDTO!=null){ print.println("Dados do E-mail de Origem: "); print.println("From: "); print.println(readEmailDataDTO.getMessageFrom()); print.println("To: "); print.println(readEmailDataDTO.getMessageTo()); print.println("CC (Carbon Copy): "); print.println(readEmailDataDTO.getMessageCC()); }
```

