web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 168
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,095 Super User 2025 Season 2 on at
    Create new functionality to receive emails with attachments in Business Central.

    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
    29,918 Super User 2025 Season 2 on at
    Create new functionality to receive emails with attachments in Business Central.
    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
    12,148 Super User 2025 Season 2 on at
    Create new functionality to receive emails with attachments in Business Central.
    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,519 Super User 2025 Season 2 on at
    Create new functionality to receive emails with attachments in Business Central.
    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
    93,155 Super User 2025 Season 2 on at
    Create new functionality to receive emails with attachments in Business Central.
    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
    168 on at
    Create new functionality to receive emails with attachments in Business Central.
    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
    168 on at
    Create new functionality to receive emails with attachments in Business Central.
    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
    168 on at
    Create new functionality to receive emails with attachments in Business Central.
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,401

#2
Sumit Singh Profile Picture

Sumit Singh 2,692

#3
YUN ZHU Profile Picture

YUN ZHU 1,935 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans