Skip to main content

How to get the count of unread emails using Email connect action

Step-by-step Approach to Get Unread Email Count:
1. Use “Email: Connect” Action
Connection Type: IMAP (recommended)
Enter email server, port, username, and password.
Save the session name (e.g., EmailSession).

2. Use “Email: Get All Messages” Action
Session Name: Use the same one as above (e.g., EmailSession)
Filter:
Check the box: "Only unread emails"
Maximum number of messages: Set a high limit like 100 or more depending on your needs
Store output in: A list variable, for example: UnreadEmailsList

3. Use “List: Get List Length” Action
Input List: UnreadEmailsList
Store result in: A number variable, for example: UnreadEmailCount

Result:
UnreadEmailCount will hold the number of unread emails.


Be careful with that solution as it may mark unread emails as read. Test it with your specific email installation.


@madhu subbegowda  - there is no action for Get All Messages in the Actions list

 


Hi ​@mahalakshmi.sambandan - I apologies, I notice that there isn't a direct "get messages" or "find emails" action as I previously mentioned.
Based on the actions available in your interface, here's how you can get the count of unread emails:

 

First, use the "Email: Connect" action to establish a connection to your email server

Configure your email server settings (Outlook, Exchange, Gmail, etc.)
Provide necessary authentication details

 

Since there's no direct "get unread count" action, you'll need to use a workaround:

Create a list variable (e.g., "emailList")
Use "Email: Save all attachments" or "Email: Save email" action which will process emails
Configure filters to target only unread emails
The action will save the emails to your specified location AND can populate your list variable

 

After the action completes, the list variable will contain the emails that matched your criteria

Create a number variable (e.g., "unreadCount")
Assign unreadCount = emailList.length


If these actions don't provide the specific unread filter you need, you might need to:

Use "Email: Connect" to connect to your server
Create a custom script using the built-in "Script" action that utilizes email APIs to get unread count
Store the result in a variable

 

Would you be able to try the "Email: Save email" approach, or would you need more help exploring the scripting option?

Note: Please remember, when using this email action, it will set the email to read status.


Reply