How to automate email in ERPNext
Short answer
ERPNext already pulls mail into Communication records through Email Account and can create documents with the Append To setting. Add a parsing layer that reads the Communication and attachments, proposes a Sales Order, Quotation or Purchase Receipt as a draft, and routes it to a person before submit.
Orders, quotes and supplier updates still arrive as email in most plants that run ERPNext. A shared inbox like sales@ or purchasing@ gets a PDF purchase order, a spreadsheet, or a two-line message saying the shipment slips a week. Someone retypes it into the Desk, and the delay and the typos are the cost.
ERPNext handles the plumbing better than people expect. Incoming Email Accounts, the Communication DocType and the Append To feature already link email to documents. What is missing is understanding: figuring out which customer, which items and which quantities, then creating a draft that a human can check in seconds.
What teams use it for
Customer PO to draft Sales Order
A PDF purchase order arrives at the orders inbox. The parser identifies the Customer, matches customer part numbers to Item codes through Item Customer Detail, and drafts a Sales Order with the PO number and delivery date.
RFQ to Quotation draft
An inbound request for quote with a list of parts becomes a draft Quotation, with unmatched lines flagged for a salesperson to resolve.
Supplier acknowledgements and date changes
Replies to Purchase Orders are matched by PO number and attached to the order, with proposed schedule_date changes shown to the buyer rather than applied.
Supplier invoices to Purchase Invoice drafts
Invoices sent by email are routed into the invoice capture flow, matched to the Purchase Order and Purchase Receipt, and left in draft for accounts.
Support and RMA triage
Emails to a support address create Issues through the standard Support settings, with the AI layer tagging urgency, serial number and product.
ERPNext integration surface
- Email Account DocType: incoming IMAP or POP settings, 'Append To' DocType, and options such as creating a document from each inbound email (Issue, Lead and others are typical).
- Communication DocType: stores each message with sender, subject, content and linked reference documents; attachments live in the File DocType.
- Email Queue and Email Domain: the outbound path, which a flow should use so replies go from the right sender and are logged.
- Notification and Auto Email Report DocTypes: scheduled summaries and alerts built without code.
- REST API and doc_events: create draft documents with docstatus 0 and subscribe to Communication creation to start parsing, running through the RQ background queue.
How it works
- 1
Configure dedicated inboxes
Separate addresses for orders, purchasing and accounts keep the parsing rules simple. Set each up as an incoming Email Account with the right Append To value.
- 2
Hook the Communication
Add a doc_events hook on Communication after_insert that enqueues a job for matching inboxes. Skip auto-replies, bounces and your own outbound mail.
- 3
Extract the content
Read the body and attachments from the File DocType. Convert PDFs and spreadsheets to text, and use OCR only when a scan has no text layer.
- 4
Match against master data
Resolve the sender to a Customer or Supplier via Contact and domain, then match part numbers using Item, Item Customer Detail or Item Supplier. Never invent a match; return candidates with confidence.
- 5
Create a draft with evidence
Insert the document in draft through the API, attach the original email, and write extracted fields next to their source snippet so a reviewer can verify quickly.
- 6
Review and learn
A reviewer submits, edits or rejects. Capture corrections as rules, such as 'ACME uses part number prefix X', to improve the next run.
Example flows
Inbound customer PO
Trigger: Email with PDF arrives at orders@ and a Communication is created.
- Job extracts the PO number, ship-to, lines and requested dates.
- Items are matched using customer part numbers; two lines are unmatched.
- A draft Sales Order is created with a Comment listing the unmatched lines.
- The order desk fixes the two lines and submits.
Result: Entry time drops to checking rather than typing, and the original email stays on the order.
Supplier date change
Trigger: A reply mentioning PO-2026-0187 arrives from a known supplier.
- Parser finds the PO number and a new date in the text.
- It adds a Comment on the Purchase Order with the proposed date and a quote of the sentence.
- A task is assigned to the buyer through ToDo.
Result: Buyers see the change immediately, and the PO schedule only changes when they approve it.
Keeping data on-prem
Email automation fits on-prem well. Keep IMAP reading, attachment storage and parsing inside your network, and run the language model on local GPUs using an open-weight model served with vLLM or Ollama so customer orders and supplier quotes are not sent to a third party. Mail itself may still transit your hosted email provider, which is outside this design. For air-gapped sites, pull mail from an internal mail server, run OCR locally, and queue documents for review in the Desk. Document retention for emails and attachments should follow your own policy.
Security checklist
- Treat email as untrusted input: strip active content, limit attachment types and sizes, and scan files before parsing.
- Guard against prompt injection in message bodies; the model should extract fields, never follow instructions found in the email.
- Verify sender identity against Contact records and warn on look-alike domains before trusting bank detail changes.
- Create drafts only; submit and payment actions remain with people.
- Log which email produced which document and who approved it.
Ways to get it done
Native Email Account plus Notification rules
Effort: Hours, no code.
Support tickets, lead capture and routing where the structure of the email does not matter.
Build a parsing app on Communication hooks
Effort: Three to six weeks for orders and RFQs with review UI.
Teams with a Frappe developer and a small set of regular senders and formats.
Partner build with Netray
Effort: Pilot on one inbox and a few top senders first.
High email volume across many customer formats, with local models and a review queue.
Pitfalls
- !Parsing your own outbound mail or auto-replies creates loops; filter by sender and headers.
- !Matching items on description text alone produces confident wrong orders; prefer exact part numbers and show candidates.
- !Auto-submitting drafts removes your last check; keep a human on submit until accuracy is proven per sender.
- !Email threads carry quoted history, so you may extract old quantities from the lower part of a reply.
- !Forgetting Communication permissions leaves staff able to see inboxes they should not.
Frequently asked questions
Can ERPNext create documents from incoming email by itself?
Partly. An incoming Email Account can append mail to a DocType such as Issue or Lead and records every message as a Communication. It does not read a PDF purchase order and build a Sales Order; that needs an added parsing step.
How accurate is AI parsing of customer purchase orders?
It depends on format consistency and master data quality. Regular senders with clean part numbers can be very reliable, while scans and free text need review. Measure per sender on real samples and keep human submit until errors are rare.
Does this need a cloud AI service?
No. Open-weight models run locally handle extraction well for structured business documents. Choose a cloud model only if your data policy allows it, and verify what retention terms apply to the content you send.
Where should drafts be created?
In the normal DocType with docstatus 0, so they appear in standard lists and respect permissions. Add a custom field such as source_communication to link back, and use a Comment to show what was extracted and what was uncertain.
What happens with attachments I cannot read?
Route them to a review queue instead of guessing. Create a ToDo for the order desk with the original email attached, and record the failure reason so you can see which formats need rules or OCR improvements.
Want Email automation working on your ERPNext?
A free 30 minute assessment: we map the integration path for your version and setup, and where it should run.
Get a free assessment