Articles
How to turn incoming emails into ERP transactions

Written by Roberto Postolovski, Founder & Tech LeadUpdated
What usually arrives by email
Each of these already has a home in the ERP. The automation's job is to get it there without someone reading, copying and re-typing.
- Purchase orders and order changes from customers
- Supplier invoices, credit notes and delivery notes
- Order confirmations and shipping updates from suppliers
- Requests that should become a ticket, task or approval
The architecture
1.Listen
Subscribe to new-mail notifications on the mailbox, so the system reacts within moments instead of checking every few minutes.
2.Queue
Acknowledge the notification immediately and process the email asynchronously, so a slow step never causes missed or repeated notifications.
3.Classify
Decide what the email is: order, invoice, change request, reply to an earlier thread, or nothing actionable.
4.Extract
Pull the fields from the body and every attachment: PDFs, spreadsheets, images and emails attached to the email.
5.Validate
Check customers, items, prices and quantities against the ERP before anything is written.
6.Write
Create or update the transaction through the ERP's API, keyed by the email's unique ID so a retry can't create a duplicate.
7.Log
Record what was received, what was extracted, what was created and who approved it.
Listening to the mailbox reliably
For Microsoft 365, Microsoft Graph change notifications deliver an event when mail arrives. Subscriptions expire and must be renewed, and Microsoft recommends handling lifecycle notifications so the app can detect and recover from missed events. Graph also throttles each app per mailbox (10,000 requests per 10 minutes and 4 concurrent requests), so bulk catch-up jobs need pacing.
For Gmail, push notifications go through Google Cloud Pub/Sub. The mailbox watch must be renewed at least every 7 days, and Google recommends renewing it daily.
On either platform, add a periodic catch-up sync that compares what's in the mailbox with what was processed. Notifications are the fast path; the sync is the safety net.
Limits and edge cases
- Reply chains and forwards: the relevant data may be in a quoted message, not the newest one
- One email, several orders: split them before validation
- Attachments inside attachments: Microsoft's standard Outlook connector doesn't support item attachments, so emails attached to emails need the Graph API
- Orders that reference items by the customer's own codes need a mapping table, maintained by a person
- Emails that look actionable but aren't (newsletters, out-of-office replies, automatic notifications) must be filtered early
What stays with your team
Anything that fails validation, anything that changes prices or terms, and anything from a sender the system hasn't seen before. Start with everything behind human approval, then switch on automatic creation one email type at a time as each proves reliable.