Filtering emails when retrieving from Outlook

Created by akaBot Support, Modified on Fri, 9 Aug, 2024 at 4:31 PM by akaBot Support

How to Write the Filter Property in the "Get Outlook Mail Messages" Activity


1. Overview

The "Filter" property in the "Get Outlook Mail Messages" activity allows you to retrieve emails from a specified folder in Outlook that match certain criteria. You can specify these conditions using either "JET Queries" or "DASL Queries." If you want to filter by "prefix match" or "keyword," you should use DASL Queries. You can also specify multiple queries by using logical operators like "AND" or "OR." Additionally, by combining this with Outlook's "Rules" feature, you can automate your email processing more efficiently and quickly.

2. How to Write

The "Filter" property must be set as a string. The entire query syntax should be enclosed in double quotes ". If you want to use a String variable in the query syntax, write it the same way as you would when concatenating strings. Here's an example using a String variable called var1:

plaintext

Copy code

"[Importance] = " + var1

"[SenderEmailAddress] = '" + var1 + "'"


3. Examples

Here are some examples of how to write filters. Please adjust the conditions as needed.

Filtering by Received date

The date format should be either "yyyy/MM/dd HH" or "MM/dd/yyyy HH"

Email to Retrieve
Example Filter Syntax
Emails received on or after 2020/8/1
"[ReceivedTime] >= '2020/8/1 0:00'"
Emails received today
"@SQL= %today(urn:schemas:httpmail:datereceived)%"
Emails received yesterday
"@SQL= %yesterday(urn:schemas:httpmail:datereceived)%"
Emails received last week
"@SQL= %lastweek(urn:schemas:httpmail:datereceived)%"
Emails received last month
"@SQL= %lastmonth(urn:schemas:httpmail:datereceived)%"
Emails received between 2020/7/1 and 2020/7/10
"[ReceivedTime] >= '2020/7/1 0:00' AND [ReceivedTime] < '2020/7/11 0:00'"


Filtering by Sender address

Email to Retrieve
Example Filter Syntax
Emails sent from [email protected]
"[SenderEmailAddress] = '[email protected]'"
Using a variable for sender email address
"[SenderEmailAddress] = '" + variable_name + "'"


Filtering by Importance

Email to Retrieve
Example Filter Syntax
Emails marked with "High" importance
"[Importance] = 2"
Emails marked with "High" importance using DASL Query
"@SQL= urn:schemas:httpmail:importance = 2"


Filtering by Subject

Email to Retrieve
Example Filter Syntax
Emails with the subject "Regarding Activities"
"[Subject] = 'アクティビティについて'"
Emails with an exact subject match
"@SQL= urn:schemas:httpmail:subject LIKE 'アクティビティについて'"
Emails with a subject starting with "Activity"
"@SQL= urn:schemas:httpmail:subject LIKE 'アクティビティ%'"
Emails containing the word "Activity" in the subject
"@SQL= urn:schemas:httpmail:subject LIKE '%アクティビティ%'"


Filtering by Body content

Email to Retrieve
Example Filter Syntax
Emails with body text starting with "Activity"
"@SQL= urn:schemas:httpmail:textdescription LIKE 'アクティビティ%'"
Emails containing the word "Activity" in the body
"@SQL= urn:schemas:httpmail:textdescription LIKE '%アクティビティ%'"


Filtering by Attachments

Email to Retrieve
Example Filter Syntax
Emails with attachments
"@SQL= urn:schemas:httpmail:hasattachment = True"


Filtering with Multiple queries

Email to Retrieve

Example Filter Syntax

Emails received on or after 2020/8/1 with attachments

"@SQL= urn:schemas:httpmail:datereceived >= '2020/8/1 0:00' AND urn:schemas:httpmail:hasattachment = True"



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article