RPA PDF and Email Automation

Most business data arrives through email and PDF documents. Invoices, purchase orders, contracts, payslips, and reports all travel as email attachments or PDF files. Automating these two channels opens up a massive range of use cases — from invoice processing to customer communications to automated reporting.

Part 1: Email Automation

Reading Emails in RPA

RPA tools connect to email clients (Outlook, Gmail, Exchange) and retrieve messages based on filters — by subject, sender, date, or folder. The bot reads each message, downloads attachments, and acts on the content.

Key Email Activities in UiPath

  • Get Outlook Mail Messages: Retrieves emails from a specified Outlook folder, filtered by unread status, subject, or sender. Returns a List of MailMessage objects.
  • Get IMAP/POP3 Mail Messages: Retrieves emails from any mail server (Gmail, Yahoo, corporate Exchange) using standard protocols.
  • Send Outlook Mail Message: Sends an email with a specified subject, body, recipients, and attachments.
  • Move Outlook Mail Message: Moves a processed email to a specified folder (e.g., move to "Done" after processing).
  • Save Attachments: Downloads all attachments from an email to a specified folder on disk.
  • Mark as Read: Marks a processed email as read so the bot does not pick it up again in the next run.

Email Processing Workflow

 TRIGGER: Bot runs every 2 hours

 1. Get Outlook Mail Messages
    Folder: "Inbox"
    Filter: Subject contains "Invoice"
    Only Unread: True
    → Returns: emailList (List of MailMessage)

 2. FOR EACH email IN emailList:
    │
    ├── Read: senderEmail = email.From
    ├── Read: emailSubject = email.Subject
    ├── Read: emailBody = email.Body
    │
    ├── Save Attachments to C:\Invoices\Incoming\
    │
    ├── Process the attachment (PDF extraction steps)
    │
    ├── Move email to "Processed" folder
    └── Mark email as Read

 3. Send summary: "X invoices processed today."

Sending Automated Emails

 Send Outlook Mail Message
 ├── To: vendorEmail variable
 ├── Subject: "Invoice Received – " + invoiceNo
 ├── Body:
 │   "Dear " + vendorName + ",
 │    Your invoice " + invoiceNo + " has been received
 │    and posted in our system as document " + sapDocNo + ".
 │    Payment will be processed within 30 days."
 └── Attachments: (optional — attach confirmation PDF)

Part 2: PDF Automation

Types of PDFs

Not all PDFs are the same. The extraction approach differs based on PDF type:

PDF TypeDescriptionExtraction Method
Native/Text PDFCreated digitally — text is selectableDirect text extraction (fast, accurate)
Scanned PDFPhysical document photographed and saved as PDFOCR (Optical Character Recognition)
Image-based PDFText is embedded as an image, not selectableOCR required
Form PDF (fillable)Has interactive fieldsPDF form field activities

Reading Native PDFs

For digital PDFs where text is selectable, UiPath's Read PDF Text activity extracts all text from the document as a single String. You then use String operations to find and extract specific values.

 Read PDF Text
 FilePath: "C:\Invoices\invoice_001.pdf"
 Output: pdfText (String variable)

 pdfText now contains the full text of the invoice.
 Example value:
 "INVOICE
  Vendor: Acme Ltd
  Invoice No: INV-2024-0451
  Date: 15 March 2024
  Amount: $1,500.75
  ..."

 Extract specific values using String methods:
 invoiceNo  = Extract text after "Invoice No: " until end of line
 amount     = Extract text after "Amount: $" and convert to Double

Reading PDFs with OCR

Scanned PDFs require OCR (Optical Character Recognition) to convert the image of text into readable text. UiPath integrates with OCR engines including Google OCR, Microsoft OCR, and Tesseract.

 Read PDF with OCR
 Engine: Google Cloud Vision (or Microsoft OCR)
 FilePath: "C:\Scanned\scanned_invoice.pdf"
 Output: ocrText (String variable)

 Note: OCR accuracy depends on scan quality.
 Clear, high-resolution scans = high accuracy.
 Low-quality or skewed scans = lower accuracy.

Document Understanding (AI-Powered Extraction)

For production-grade invoice processing, UiPath offers Document Understanding — an AI module that can extract structured data from PDFs even when layout varies across different vendors. Instead of writing custom string-parsing code for each vendor's invoice format, you train a model once and it handles all formats.

 Document Understanding Pipeline:
 ─────────────────────────────────────────────
 PDF Input
    │
    ▼
 Digitise (convert to machine-readable format)
    │
    ▼
 Classify (identify document type: invoice, PO, contract)
    │
    ▼
 Extract (pull named fields: Vendor, Amount, Date, Items)
    │
    ▼
 Validate (human review if confidence score is below threshold)
    │
    ▼
 Output: Structured data (DataTable or JSON)

Filling PDF Forms

Some processes require filling in a PDF form and submitting it. RPA handles this by:

  • Opening the PDF in Adobe Acrobat or a browser PDF viewer
  • Using Type Into activities to fill each form field by selector
  • Clicking the Submit or Save button

Combined PDF and Email Example: Payslip Distribution

 Payroll team provides Excel with: Employee | Email | PDF Path

 FOR EACH row IN payrollData:
   ├── Read: employeeName = row("Name")
   ├── Read: employeeEmail = row("Email")
   ├── Read: payslipPath = row("PDF Path")
   │
   ├── Send Outlook Mail Message:
   │   To: employeeEmail
   │   Subject: "Your Payslip – March 2024"
   │   Body: "Dear " + employeeName + ", please find your payslip attached."
   │   Attachment: payslipPath
   │
   └── Log: employeeName + " | Sent | " + Now.ToString()

Summary

Email automation connects the bot to Outlook or any mail server, enabling it to read, filter, download attachments, send responses, and organise processed emails. PDF automation extracts data from native PDFs using text activities, from scanned PDFs using OCR, and from complex varying-format documents using AI-powered Document Understanding. Combined, PDF and email automation covers some of the highest-volume, most valuable use cases in any RPA programme.

Leave a Comment

Your email address will not be published. Required fields are marked *