It seems this should be a simple thing. I’m just learning about email integrations with Gmail. How do I get a count of all emails in a folder? I’m looping through them using a for each activity, but is there a way to do get a count quickly as a whole, without having to loop through them? I want to present to the user how many emails are in the folder before I start doing something to them. Then, check again to be sure that the automation succeeded.
You can go get mails and then use outputvariable.count to get the count of mails…but again it has a limit of 100 or 1000 mails so if there are more than that then you would get only those many
Cheers
I don’t see “get mails” as an option under Gmail. Also, I don’t see any output variable in the properties for “Use Gmail” activity?
To get the count of Gmail emails in a folder in UiPath, you can use the IMAP (Internet Message Access Protocol) activities. Here’s a step-by-step guide to achieve this:
- Install the IMAP Activities Package: If you haven’t already installed the IMAP activities package, you can do so from the Manage Packages window in UiPath Studio. Search for “UiPath.Mail.Activities” and install it.
- Use the IMAP Mail Message Activity to Connect to Gmail: Drag and drop the “IMAP Mail Message” activity onto your workflow. Configure the properties of this activity to connect to your Gmail account. Set the following properties:
-
Server: “imap.gmail.com”
-
Port: 993
-
Email: Your Gmail email address
-
Password: Your Gmail password
-
SecureConnection: True
-
MarkAsRead: False
- Use the IMAP Get Mail Messages Activity to Retrieve Emails: Drag and drop the “IMAP Get Mail Messages” activity onto your workflow. Connect it after the “IMAP Mail Message” activity. Configure the properties of this activity as follows:
- MailFolder: Specify the folder from which you want to retrieve emails (e.g., “Inbox”).
- Top: Set it to a large number to ensure you retrieve all emails in the folder.
- Use an Assign Activity to Count the Emails: Add an Assign activity after the “IMAP Get Mail Messages” activity. In the To field, create a new variable to store the count of emails (e.g., emailCount). In the Value field, set it to mailMessages.Count.
- Use a Write Line Activity to Display the Count: Drag and drop a Write Line activity after the Assign activity. Set the Text property to something like "Number of emails in folder: " + emailCount.ToString().
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.