Project 4 — Intermediate
Email Triage & Attachment Bot
Shared inbox me roz 300+ mails — invoices, queries, complaints. Sab manually padh ke folder me daalna. Is project me bot banayenge jo mails automatically classify kare, attachments save kare, aur acknowledgment reply bheje.
Project kya karega?
WHAT
Bot Outlook se unread mails laayega, keyword rules se classify karega (invoice → Finance folder, complaint → Support, query → Sales), har category ke attachments alag folder me save karega, aur sender ko template acknowledgment reply karega. Processed mails read-mark + folder move.
WHEN
Shared mailboxes (info@, support@, sales@) — jab inbox me 100+ mails roz aayein aur manual sorting 1 ghanta le. Email triage RPA ki sabse visible use case hai — result turant dikhta hai.
WHERE
Customer support teams, helpdesks, HR departments (leave queries), sales teams (lead qualification). Har company ka inbox hai — har company ko chahiye.
Step-by-step build
Main.xaml (Sequence)
|
+-- Try Catch
| +-- Get Outlook Mail Messages
| | Filter: "[Unread]=true"
| | OnlyMessagesWithAttachments: False
| | Top: 50 (batch limit - har run me 50)
| | -> dtMails
| +-- For Each mail in dtMails
| | +-- Sequence: Classify & Route
| | +-- Assign strSubject = mail.Subject.ToLower
| | +-- Assign strFrom = mail.From.ToString.ToLower
| | +-- If strSubject.Contains("invoice") OR strSubject.Contains("bill")
| | | +-- Save Attachments mail to "C:\Mail\Finance\"
| | | +-- Move mail to folder "Finance"
| | +-- Else If strSubject.Contains("complaint") OR strSubject.Contains("issue")
| | | +-- Save Attachments mail to "C:\Mail\Support\"
| | | +-- Move mail to folder "Support"
| | +-- Else If strFrom.Contains("gmail.com") OR strFrom.Contains("yahoo")
| | | +-- Move mail to folder "Sales-Query"
| | +-- Else
| | +-- Move mail to folder "Other"
| | +-- Send Outlook Mail Message
| | To: mail.From
| | Subject: "Re: " + mail.Subject
| | Body: "Aapka mail mil gaya hai - team 24 ghante me reply karegi."
| | IsDraft: False
| +-- Catch
| +-- Log Message LogLevel.Error
Rules ko Config me daalo
Upar ke If-Else rules production me Config.xlsx ki sheet me jaate hain — Support team khud keywords badal sake:
# Config.xlsx - TriageRules sheet
Keyword Folder
invoice Finance
bill Finance
po Finance
complaint Support
issue Support
refund Support
quote Sales
demo Sales
# Bot: For Each Row in TriageRules -> strSubject.Contains(keyword)
# Rules update = Excel edit, bot redeploy nahi
Error handling
- Dobara process: Ek hi run me mail dobara na aaye — "Mark as read" step daalo (Outlook me mail read ho jayega to next run me Unread filter se bahar).
- Attachment name clash: Save Attachments same-name file overwrite kar sakta hai — timestamp prefix lagao (mail.EntryId + "_" + fileName).
- Reply fail: Send fail ho to mail ko processed mat mark karo — next run retry karega.
- Huge attachments (50MB+): size check lagao, skip + log, manually handle.
Enterprise tips
- Batch limit (Top: 50) zaroori — 5000 unread mails ek run me Outlook hang kar dega.
- Gmail users ke liye IMAP activities (Get IMAP Mail Messages) — Outlook na ho tab.
- Rules sheet ke saath ek audit sheet bhi rakho: timestamp, mail id, folder — kis mail ko kahan daala.
- Auto-reply hamesha template se — personalization galat ho sakta hai. Sender name insert karo, baaki fixed.
Exercise
Question: Get Outlook Mail Messages me sirf anpadh mails laane ka filter string kya hogi? (2 words max)
Question: Process hone ke baad mail ko read mark karne ki activity ka naam? (2-3 words)
Common mistakes
- No batch limit: Inbox me 2000 unread = bot 2000 mails ek run me process karega — Outlook crash. Top limit lagao.
- Rules hardcoded: Har client ka keyword alag — Config sheet se chalao.
- Mark-as-read skip: Dobara process honge mails — duplicates replies jayenge customers ko.
- Sensitive mails ka data log: Production me mail content log mat karo — metadata (sender, subject) hi kaafi hai. GDPR/compliance.
Project ban gaya? Ab next project pe chalte hain — SAP Data Entry Bot.