---
sourceDocument: Yokohama Security Management
sourceDocumentLink: https://www.servicenow.com/docs/r/yokohama/security-management

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama Security Management

ft:clusterId :

    - security

bundleId :

    - security

workflow :

    - Technology


---

# Microsoft Exchange - Perform Email Search and Deletion flow

# Microsoft Exchange - Perform Email Search and Deletion flow {#ariaid-title1}

* Release version: Yokohama
* 
* Updated January 30, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

When the Microsoft Exchange - Perform Email Search and Deletion flow is executed, it searches the Exchange server using the search query provided, and returns the details to the on-premises
instance.

## Before you begin

Role required: sn_si.analyst

## About this task

The Microsoft Exchange - Perform Email Search and Deletion flow is executed when email searches are set up and the Delete from Email Server(s) or Search on Email Server(s) button are pressed.

Actions specific to this integration are described here. For more information on other actions, see [Common Security Operations integration flows and orchestration activities](https://www.servicenow.com/docs/PW3RL1qTedi7sbW9W_h~Bg "Many of the flows associated with third-party integrations include the same activities. For example, activities for beginning and completing processing.").  
The flow actions include:

* [Create Compliance Search Action](https://www.servicenow.com/docs/req6J1wBxw1le1QnjlyINg "The Create Compliance Search action creates a compliance search for emails in the designated Exchange server(s) using the search queries defined and returns the name of compliance search created.")
* [Check Compliance Search Status Action](https://www.servicenow.com/docs/Q2wTEKgvgvctcpSbKeIXtQ "The Check Compliance Search Status action check the status of created compliance search on exchange server and if the status is completed return the information regarding email search found for the compliance search.")
{#ms-exch-perform-email-search-deletion-wf__ul_rxy_k5b_3cc}

## Create Compliance Search Preview Action {#ariaid-title2}

The Create Compliance Search Preview Action creates a new compliance search action of type preview on the exchange server for the created compliance search.

### Input variables {#create-compliance-search-preview-action-activity__section_alh_hfm_3z}

Input variables determine the initial behavior of the action.
{#create-compliance-search-preview-action-activity__table_pgm_tfy_jr__entry__2}

| Variable | Description |
|-|-|
| targetId | Mandatory target host identifier field where the Exchange Server is located. |
| searchName | Mandatory name of compliance search created on exchange server. |
[ ]

{#create-compliance-search-preview-action-activity__table_pgm_tfy_jr}

### Exit Conditions {#create-compliance-search-preview-action-activity__section_w4g_nsb_v1b}

Possible exit conditions for this action are:
{#create-compliance-search-preview-action-activity__table_x4g_nsb_v1b__entry__2}

| Variable | Description |
|-|-|
| Complete | When compliance search action is successfully created. |
| Error Creating Action | When creation of compliance search action fails due to exception in exchange server. |
| Error | When exception occurs in flow action. |
[Table 1. Exit Conditions]

{#create-compliance-search-preview-action-activity__table_x4g_nsb_v1b}

## Check Preview Action Status {#ariaid-title3}

The Preview Action Status checks the status of compliance search action of type preview and returns the preview information of the emails found like recipient, sender, subject, email date received.

### Input variables {#check-preview-action-status-activity__section_alh_hfm_3z}

Input variables determine the initial behavior of the activity.
{#check-preview-action-status-activity__table_pgm_tfy_jr__entry__2}

| Variable | Description |
|-|-|
| targetId | Mandatory target host identifier field where the Exchange Server is located. |
| searchName | Mandatory name of compliance search created on exchange server. |
[ ]

{#check-preview-action-status-activity__table_pgm_tfy_jr}

### Output variables {#check-preview-action-status-activity__section_cw4_gsb_v1b}

The output variables contain data that can be used in subsequent actions.
{#check-preview-action-status-activity__table_bnj_jfy_jr__entry__2}

| Variable | Description |
|-|-|
| response | Contains the status of compliance search action and the preview information of the email found as a part of compliance search. |
[Table 2. Output variables]

{#check-preview-action-status-activity__table_bnj_jfy_jr}

### Exit Conditions {#check-preview-action-status-activity__section_w4g_nsb_v1b}

Possible exit conditions for this action are:
{#check-preview-action-status-activity__table_x4g_nsb_v1b__entry__2}

| Variable | Description |
|-|-|
| Preview in Progress | When status of compliance search action is in progress. |
| No Mail Found | When status of compliance search action is completed, and no emails are found as a part of compliance search. |
| Preview Complete | When status of compliance search action is completed, and emails are found as a part of compliance search. |
| Error Checking Status | When status checking fails due to exception in exchange server. |
| Error | When exception occurs in workflow activity. |
[Table 3. Exit Conditions]

{#check-preview-action-status-activity__table_x4g_nsb_v1b}

## Create Compliance Search Delete Action {#ariaid-title4}

The Create Compliance Search Delete Action creates a new compliance search action of type purge on the exchange server for the created compliance search.

### Input variables {#create-compliance-search-delete-action-activity__section_alh_hfm_3z}

Input variables determine the initial behavior of the action.
{#create-compliance-search-delete-action-activity__table_pgm_tfy_jr__entry__2}

| Variable | Description |
|-|-|
| targetId | Mandatory target host identifier field where the Exchange Server is located. |
| searchName | Mandatory name of compliance search created on exchange server. |
[ ]

{#create-compliance-search-delete-action-activity__table_pgm_tfy_jr}

### Exit Conditions {#create-compliance-search-delete-action-activity__section_w4g_nsb_v1b}

Possible exit conditions for this action are:
{#create-compliance-search-delete-action-activity__table_x4g_nsb_v1b__entry__2}

| Variable | Description |
|-|-|
| Complete | When compliance search action is successfully created. |
| Error Creating Action | When creation of compliance search action fails due to exception in exchange server. |
| Error | When exception occurs in flow action. |
[Table 4. Exit Conditions]

{#create-compliance-search-delete-action-activity__table_x4g_nsb_v1b}

## Check Delete Action Status {#ariaid-title5}

The Check Delete Action Status checks the status of compliance search action of type purge and performs soft delete operation on the exchange server for the emails found as a part of compliance search.

### Input variables {#check-delete-action-status-activity__section_alh_hfm_3z}

Input variables determine the initial behavior of the action.
{#check-delete-action-status-activity__table_pgm_tfy_jr__entry__2}

| Variable | Description |
|-|-|
| targetId | Mandatory target host identifier field where the Exchange Server is located. |
| searchName | Mandatory name of compliance search created on exchange server. |
[ ]

{#check-delete-action-status-activity__table_pgm_tfy_jr}

### Output variables {#check-delete-action-status-activity__section_cw4_gsb_v1b}

The output variables contain data that can be used in subsequent actions.
{#check-delete-action-status-activity__table_bnj_jfy_jr__entry__2}

| Variable | Description |
|-|-|
| response | Contains the status of compliance search action and count of emails deleted, which were found as a part of compliance search. |
[Table 5. Output variables]

{#check-delete-action-status-activity__table_bnj_jfy_jr}

### Exit Conditions {#check-delete-action-status-activity__section_w4g_nsb_v1b}

Possible exit conditions for this action are:
{#check-delete-action-status-activity__table_x4g_nsb_v1b__entry__2}

| Variable | Description |
|-|-|
| Delete in Progress | When status of compliance search action is in progress. |
| No Mail Found | When status of compliance search action is completed, and no emails are deleted as a part of compliance search. |
| Delete Complete | When status of compliance search action is completed, and emails are deleted as a part of compliance search. |
| Error Checking Status | When status checking fails due to exception in exchange server. |
| Error | When exception occurs in flow action. |
[Table 6. Exit Conditions]

{#check-delete-action-status-activity__table_x4g_nsb_v1b}

## Remove Compliance Search Action {#ariaid-title6}

The Remove Compliance Search action removes the created compliance search from exchange server.

### Input variables {#remove-compliance-search-activity__section_alh_hfm_3z}

Input variables determine the initial behavior of the action.
{#remove-compliance-search-activity__table_pgm_tfy_jr__entry__2}

| Variable | Description |
|-|-|
| targetId | Mandatory target host identifier field where the Exchange Server is located. |
| searchName | Mandatory name of compliance search created on exchange server. |
[ ]

{#remove-compliance-search-activity__table_pgm_tfy_jr}

