Search Mail
Searches for emails in a specified Microsoft Outlook folder using Outlook's powerful filter syntax. This node allows you to perform advanced searches based on subject, sender, date, and other email properties.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is set to true, no error will be caught and the automation will continue running. If a Catch node is used, it will have no effect.
Inputs
- Account Mail Address - The email account address to search in (e.g.,
user@company.com). This must match an account configured in Outlook. - Mail Folder - The folder name to search in. Default is
INBOX. Common values include:INBOX- Main inbox folderSent Items- Sent messagesDrafts- Draft messagesDeleted Items- Trash folder- Custom folder names you've created
- Filter - Outlook filter expression to find specific emails. Uses Outlook's filter syntax with square brackets for properties. Example:
[Subject] = 'Invoice'
Outputs
- Result - A list of Mail objects matching the search criteria, each containing:
from- Sender's email addressto- Array of recipient email addressescc- Array of CC recipient email addressessubject- Email subject linebody- Email body content (plain text)datetime- Date and time the email was receivedentryId- Unique identifier for the email (used with Move Mail and Save Attachments nodes)storeId- Store identifier for the email account
Options
This node has no additional options.
Outlook Filter Syntax
The Filter input uses Outlook's DASL (DAV Searching and Locating) filter syntax. Here are common filter patterns:
Basic Property Filters
[Subject] = 'Invoice' // Exact subject match
[SenderEmailAddress] = 'user@example.com' // Exact sender match
[SenderName] = 'John Smith' // Sender name
Partial Text Matching
[Subject] LIKE '%Invoice%' // Subject contains "Invoice"
[Subject] LIKE 'Invoice%' // Subject starts with "Invoice"
[Subject] LIKE '%Invoice' // Subject ends with "Invoice"
Date Filters
[ReceivedTime] > '2024-01-01' // After specific date
[ReceivedTime] >= '2024-01-01 09:00' // After date and time
[ReceivedTime] < '2024-12-31' // Before specific date
Combining Filters
[Subject] LIKE '%Invoice%' AND [SenderEmailAddress] = 'billing@company.com'
[ReceivedTime] > '2024-01-01' AND [Subject] LIKE '%Report%'
[Subject] = 'Urgent' OR [Subject] = 'Important'
Other Common Properties
[UnRead] = true // Only unread emails
[Importance] = 1 // High importance (0=Low, 1=Normal, 2=High)
[HasAttachments] = true // Has attachments
[To] LIKE '%myemail@company.com%' // Recipient contains email
[CC] LIKE '%team@company.com%' // CC contains email
[Body] LIKE '%urgent%' // Body contains text
Example Usage
Search by Subject
// Filter input: [Subject] = 'Monthly Report'
const emails = $.Result;
console.log(`Found ${emails.length} emails with subject "Monthly Report"`);
for (const email of emails) {
console.log(`From: ${email.from} - Date: ${email.datetime}`);
}
Search by Sender
// Filter input: [SenderEmailAddress] = 'manager@company.com'
const managerEmails = $.Result;
console.log(`Found ${managerEmails.length} emails from manager`);
Search for Recent Invoices
// Filter input: [Subject] LIKE '%Invoice%' AND [ReceivedTime] > '2024-01-01'
const recentInvoices = $.Result;
// Process each invoice email
for (const invoice of recentInvoices) {
console.log(`Invoice from: ${invoice.from}`);
console.log(`Date: ${invoice.datetime}`);
console.log(`Subject: ${invoice.subject}`);
console.log('---');
}
Search Unread Emails from Specific Sender
// Filter input: [UnRead] = true AND [SenderEmailAddress] = 'support@company.com'
const unreadSupportEmails = $.Result;
if (unreadSupportEmails.length > 0) {
console.log(`Found ${unreadSupportEmails.length} unread support emails`);
// Process support requests...
}
Search Emails with Attachments
// Filter input: [HasAttachments] = true AND [Subject] LIKE '%Report%'
const reportsWithAttachments = $.Result;
// Extract entry IDs for saving attachments
const emailsForProcessing = reportsWithAttachments.map(email => ({
entryId: email.entryId,
storeId: email.storeId,
subject: email.subject,
from: email.from
}));
return emailsForProcessing;
Complex Search with Multiple Conditions
// Filter input: ([Subject] LIKE '%Invoice%' OR [Subject] LIKE '%Receipt%') AND [ReceivedTime] > '2024-06-01' AND [HasAttachments] = true
const financialDocuments = $.Result;
console.log(`Found ${financialDocuments.length} financial documents with attachments`);
// Group by sender
const bySender = {};
for (const email of financialDocuments) {
if (!bySender[email.from]) {
bySender[email.from] = [];
}
bySender[email.from].push(email);
}
console.log('Documents by sender:', Object.keys(bySender));
Search and Extract Specific Information
// Filter input: [Subject] LIKE '%Order Confirmation%' AND [ReceivedTime] > '2024-11-01'
const orderEmails = $.Result;
// Extract order information from subjects
const orders = orderEmails.map(email => {
// Assuming subject format: "Order Confirmation - #12345"
const orderMatch = email.subject.match(/#(\d+)/);
return {
orderNumber: orderMatch ? orderMatch[1] : null,
customer: email.from,
date: email.datetime,
entryId: email.entryId
};
});
return orders;
Search by Date Range
// Filter input: [ReceivedTime] >= '2024-11-01' AND [ReceivedTime] <= '2024-11-30'
const novemberEmails = $.Result;
console.log(`Emails in November 2024: ${novemberEmails.length}`);
// Calculate total emails per day
const emailsByDate = {};
for (const email of novemberEmails) {
const date = email.datetime.toISOString().split('T')[0];
emailsByDate[date] = (emailsByDate[date] || 0) + 1;
}
console.log('Emails per day:', emailsByDate);
Search High Priority Emails
// Filter input: [Importance] = 2 AND [UnRead] = true
const urgentUnread = $.Result;
if (urgentUnread.length > 0) {
console.log(`ALERT: ${urgentUnread.length} unread high-priority emails!`);
for (const email of urgentUnread) {
console.log(`- From ${email.from}: ${email.subject}`);
}
}
Tips for Effective Use
-
Test Filters in Outlook First: You can test your filter syntax directly in Outlook using the "Filter" feature in the search bar to validate the syntax before using it in automation.
-
Use LIKE for Flexibility: The
LIKEoperator with%wildcards is more flexible than exact matches with=. -
Date Format: Use ISO format (YYYY-MM-DD) or include time (YYYY-MM-DD HH:MM) for date filters.
-
Case Sensitivity: Text comparisons in Outlook filters are generally case-insensitive.
-
Property Names: Property names in square brackets must match Outlook's property names exactly. Common ones are
Subject,SenderEmailAddress,ReceivedTime,UnRead,HasAttachments. -
Combining Conditions: Use
ANDandORoperators. Use parentheses()to group complex conditions. -
Performance: More specific filters perform better. Searching by date range is faster than searching entire mailboxes.
-
Email Sorting: Results are automatically sorted by received time in descending order (most recent first).
Common Errors and Solutions
Error: Account Mail Address cannot be empty
- Solution: Provide a valid email address that is configured in Microsoft Outlook.
Error: Mail Folder cannot be empty
- Solution: Specify a valid folder name such as
INBOXor the exact name of your custom folder.
Error: Filter cannot be empty
- Solution: Provide a valid Outlook filter expression. Example:
[Subject] = 'Test'
No results despite having matching emails
- Solution: Verify that:
- The filter syntax is correct (property names in square brackets)
- Property names match Outlook properties exactly
- Text values are enclosed in single quotes
'value' - Date format is correct (YYYY-MM-DD)
- You're searching in the correct folder
Invalid filter syntax error
- Solution: Check that:
- Property names are in square brackets:
[PropertyName] - String values are in single quotes:
'value' - Date format is valid
- Operators are correct (
=,LIKE,>,<,AND,OR) - Parentheses are balanced in complex filters
- Property names are in square brackets:
Search is too slow
- Solution:
- Add date range filters to limit search scope
- Search in specific folders rather than all folders
- Make filters more specific
- Consider using indexed properties like
ReceivedTimeandSubject
Special characters in search text
- Solution: If searching for text with apostrophes or special characters, use proper escaping or consider using wildcards with
LIKEoperator.