Automated Email Categorization and Filing Bot using UiPath

Submission type

Generic use case

Name

Bhuvaneswaran B

Industry category in which use case would best fit in (Select up to 2 industries)

Universities/Academy

Complexity level

Intermediate

Summary (abstract)

This project automates the process of organizing incoming emails into predefined folders using UiPath RPA. The bot reads categorization rules from an Excel file containing sender–folder mappings, retrieves unread emails via IMAP, matches senders with the rules, and moves emails to the corresponding folders. This reduces manual effort, ensures important emails are not missed, and improves inbox management efficiency.

Detailed problem statement

Ms. B. Ajitha, a final-year CSE student at Rajalakshmi Engineering College and a UiPath Student Developer Champion (SDC) for 2025–26, receives a high volume of emails in her personal inbox every day from multiple trusted sources—Training Department (training@rajalakshmi.edu.in), Placement Department (placement@rajalakshmi.edu.in), LinkedIn notifications, UiPath Community announcements, and others—which makes it easy to overlook time-sensitive messages. To reduce the risk of missing important communications, she manually created labels/folders named Training, Placement, LinkedIn, and UiPath and began moving messages into them, but soon realized that daily manual triage was tedious, error-prone, and time-consuming. She approached Mr. B. Bhuvaneswaran (Assistant Professor, SG, CSE) for an automation-first solution using UiPath. The proposed RPA bot must automatically classify and file incoming mail using a rules list stored in Rules.xlsx (two columns: Sender, Folder), operate over IMAP, and work specifically on Unread messages. On execution, the bot should 1) read Rules.xlsx into a DataTable (dtRules), 2) connect to the mailbox via Get IMAP Mail Messages and fetch unread items from Inbox, 3) iterate each email (For Each MailMessage) and compare its From address (and optionally domain) against the Sender patterns in dtRules by looping For Each Row; if a match is found, the message must be moved to the mapped folder/label using Move IMAP Mail Message (creating the folder if it does not exist), 4) mark processed items as read or leave unread per a configuration flag, 5) log every action (MessageId/Subject/From/MatchedRule/TargetFolder/Timestamp) and unmatched senders to a CSV/Excel audit file for review, and 6) surface basic metrics (total unread scanned, moved by folder, unmatched count, errors) at the end. The solution must be resilient to network hiccups and IMAP throttling (retry with exponential back-off), handle case/whitespace variations in email addresses, support wildcard/domain matching (e.g., *@linkedin.com, *@uipath.com), and safely skip messages with no matching rule while recording them for future rule enrichment. Security expectations include storing credentials in Windows Credential Manager/Orchestrator Assets, read-only access to Rules.xlsx from a configurable path, and no hard-coded secrets. Success is defined as ≥99% accurate filing, a complete audit trail, and a daily execution time under a few minutes for typical volumes; the bot should be schedulable (e.g., every 30 minutes) or triggered on demand, giving Ajitha a reliable, maintainable, and extensible email-organization assistant that prevents important Training/Placement/LinkedIn/UiPath communications from being missed.

Detailed solution

Prerequisites & Setup

  1. Enable IMAP on the mailbox (e.g., Gmail, Outlook, Zoho).
  1. Create the labels/folders in your mailbox first: Training, Placement, LinkedIn, UiPath. (If a folder is missing, Gmail usually creates the label on first move; for others, pre-create to avoid errors.)
  2. Create Rules.xlsx (Sheet: Rules) with columns:
  • Sender (e.g., training@rajalakshmi.edu.in, @linkedin.com, notifications@uipath.com)
  • Folder (e.g., Training, Placement, LinkedIn, UiPath)
  1. Store credentials securely (recommended):
  • Windows Credential Manager / Orchestrator Assets (e.g., IMAP_User, IMAP_Password).

Variables & Arguments

Create these variables (Scope: Main):

  • imapServer (String) – e.g., “imap.gmail.com
  • imapPort (Int32) – 993
  • emailUser (SecureString or String, depending on how you fetch)
  • emailPass (SecureString)
  • topCount (Int32) – e.g., 0 (0 = fetch all unread)
  • onlyUnread (Boolean) – True
  • rulesPath (String) – full path to Rules.xlsx
  • dtRules (DataTable)
  • mails (List<System.Net.Mail.MailMessage>)
  • dtAudit (DataTable) – for logging moves/unmatched

Read Rules.xlsx

  • Excel Process Scope / Use Excel File → rulesPath
  • Read Range (Sheet: Rules, range: blank to auto) → output dtRules

Get IMAP Mail Messages
Get IMAP Mail Messages (from UiPath.Mail.Activities):

  • Server: imapServer
  • Port: imapPort
  • Email / Password: from Assets/Credential Manager or input
  • SecureConnection: True
  • MailFolder: “INBOX”
  • Top: topCount (0 = no limit)
  • OnlyUnreadMessages: onlyUnread
  • Output: mails

Matching Strategy (Exact, Domain, or Regex)
Decide how to match:

  • Exact: fromAddress = “training@rajalakshmi.edu.in”
  • Domain: rule holds @linkedin.com and you match when fromAddress.EndsWith(“@linkedin.com”)
  • Regex (flexible): store patterns like .*@UiPath.com$

Loop Through Emails
For Each mail in mails (TypeArgument: System.Net.Mail.MailMessage)

  • Create locals:
  • matchedRule (String) = “”
  • targetFolder (String) = “”
  • isMoved (Boolean) = False

Evaluate Rules
For Each Row r in dtRules.Rows

Move Message (if matched)

If matchedRule <> “”:

  • Move IMAP Mail Message:
  • MailMessage: mail
  • MailFolder: targetFolder (For Gmail, this applies a label; for standard IMAP, it moves to the folder.)
  • Set isMoved = True

Expected impact of this automation

Implementing this UiPath automation will have the following impacts:

Time Savings – Eliminates the need to manually check and move emails, saving significant daily effort for users.

Improved Email Management – Ensures emails are consistently categorized into the correct folders, reducing clutter and making retrieval easier.

Error Reduction – Removes the possibility of human error in filing important emails into wrong folders or missing them altogether.

Productivity Boost – Allows users to focus on priority tasks rather than spending time on repetitive email sorting.

Scalability – Can easily adapt to new email sources or updated categorization rules by modifying the Excel rule file without changing the bot logic.

Consistency – Maintains uniform email organization across multiple users or accounts following the same rule set.

Better Response Time – Important emails (e.g., from Training or Placement departments) are quickly accessible, ensuring timely actions.

UiPath products used (select up to 4 items)

UiPath Studio

Automation Applications

Excel, Email

Integration with external technologies

NA

TO-BE workflow/architecture diagram (file size up to 4 MB)

Other resources

NA