To build a custom email receiving and attachment handling feature in Business Central, here's a high-level approach you can follow:
Set Up Email Integration via Microsoft Graph API or SMTP/IMAP
Use Microsoft Graph API (preferred for Exchange/Outlook).
Alternatively, use DotNet types to connect to mailboxes via IMAP/SMTP.
Create a Scheduled Job Queue or Codeunit
Poll the mailbox at intervals.
Read unread messages with attachments.
Parse the Email and Attachments
Use AL code to extract the subject, body, sender, etc.
Use TempBlob or InStream to read attachments and store in custom tables or process further.
TempBlob
InStream
Store/Process Attachments
Save to custom table (e.g., Email Attachment Buffer).
Email Attachment Buffer
Optionally, trigger workflows, validation, or auto-create documents (Sales/Purchase/etc.).
Add Logging and Error Handling
Capture failed emails or unsupported file types.
Log for audit trail.
Example snippet for reading attachment (if fetched from external API):
var InStream: InStream; TempBlob: Codeunit "Temp Blob"; begin // Assume InStream is loaded from your email API TempBlob.CreateInStream(InStream); // Save or process the stream as needed end;
You can’t directly receive email in BC, so external integration (Azure Function / API App) might be needed to push email data to BC.
You must handle authentication (OAuth2) if using Microsoft Graph.
✅ Mark the checkbox below if this answer helped you. (For advanced implementation or support, feel free to connect via LinkedIn: Sohail Ahmad)
OCR is a third-party API, and we want to build our own extension.
Business Case:
We receive emails from customers via Outlook or Gmail accounts with Excel or PDF file attachments. Our requirement is to read the data from these attached files and create Sales Orders in Business Central.
The current OCR system does not provide a standard option for creating Sales Orders directly, which is why we are exploring a custom solution.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 3,401
Sumit Singh 2,692
YUN ZHU 1,935 Super User 2025 Season 2