web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Create new functionality to receive emails with attachments in Business Central.

(2) ShareShare
ReportReport
Posted on by 236
Hi All,
 
We want to create a new custom functionality to process received emails with attachments and read the attached files. We cannot use the standard Incoming Documents or OCR functionality. Please suggest how we can implement this.
 
Thanks.
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,169 Super User 2026 Season 1 on at

    To build a custom email receiving and attachment handling feature in Business Central, here's a high-level approach you can follow:

     
     

    🔧 Implementation Steps

     

    1.  

      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.



      •  

    2.  

      Create a Scheduled Job Queue or Codeunit

       

      •  

        Poll the mailbox at intervals.


      •  

        Read unread messages with attachments.



      •  

    3.  

      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.



      •  

    4.  

      Store/Process Attachments

       

      •  

        Save to custom table (e.g., Email Attachment Buffer).


      •  

        Optionally, trigger workflows, validation, or auto-create documents (Sales/Purchase/etc.).



      •  

    5.  

      Add Logging and Error Handling

       

      •  

        Capture failed emails or unsupported file types.


      •  

        Log for audit trail.



      •  


    6.  
     
     

    📦 AL Code Hint

     

    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;
    
     
     

    ✅ Final Notes

     

    •  

      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)

  • Valentin Castravet Profile Picture
    32,157 Super User 2026 Season 1 on at
    Can you explain why OCR can't be used? You could use existing third-party apps like Continia Document Capture.  
  • Suggested answer
    Jainam M. Kothari Profile Picture
    15,732 Super User 2026 Season 1 on at
    Hello,
     
    To implement custom email processing in Business Central without using standard Incoming Documents or OCR, you can build a solution using tools like Power Automate or Azure Logic Apps to monitor an email inbox, extract attachments, and send them to Business Central via a custom API. In Business Central, create a custom API page and Codeunit to receive, parse, and process the file content (e.g., CSV, XML, PDF), storing relevant data and logging email metadata. This approach ensures flexibility, automation, and integration while maintaining control over how attachments are handled and processed.
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,547 Super User 2026 Season 1 on at
    Could you please explain why you can't use the OCR functionality, or share the business case for what you're trying to implement?
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
  • Suggested answer
    YUN ZHU Profile Picture
    99,084 Super User 2026 Season 1 on at
    If you can't use OCR service, you can't read the content of the file even if you use other methods, such as Azure Function, Power Automate. I recommend using the standard method first.
    Incoming documents:
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • CU08050848-0 Profile Picture
    236 on at
    Hello Ramesh,
     
    Thank you for your response.

    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.

     
  • CU08050848-0 Profile Picture
    236 on at
    Hello  Valentin Castravet,
     
    Thank you for your response.
     
    The current OCR system does not provide a standard option for creating Sales Orders directly, which is why we are exploring a custom solution.
     
    Continia Document Capture is currently not available for the India (IN) localization.
  • CU08050848-0 Profile Picture
    236 on at
    Hello Sohail Ahmed,
     
    Thanks for your reply. Could you please share any reference code or documentation?

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,946 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,177 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 555 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans