Skip to main content

Archive invoice attachments in emails to Sharepoint

Manually sorting and saving invoices from your inbox is a repetitive, time-consuming task. This Action Flow automates the process by identifying incoming invoices, organizing them into dedicated sender folders, and saving them directly to SharePoint or OneDrive. By implementing this solution, you ensure a standardized naming convention and a centralized, searchable archive without manual intervention.

This Action Flow automates the document ingestion process through three primary stages:

  1. Email parsing: Monitors incoming mail and selects messages containing "invoice" in the subject line or body.

  2. Attachment filtering: Scans selected emails to identify and isolate attachments with "invoice" in the filename.

  3. Dynamic archiving

    • Checks for an existing folder named after the sender.

    • If no folder exists, the flow creates one automatically.

    • The invoice is then uploaded directly to the sender-specific folder.

Action Flow for the Parse Email module in which the module's output is being routed to different Upload invoice modules.

Below you will find the step-by-step guide for configuring each module of the above Action Flow.

In the example provided above, mails are gathered from a mail account using the "Email" action. The screenshot on the right shows how this module has been configured.

You additionally have the possibility to filter specific mails.

Folder: You can choose a folder where the mails you want to use are currently saved (we chose the INBOX in the example)

Criteria: You can define more Criteria like only choosing unread/read mails or all

Sender email address: you can define a sender from whom the mails to use will come/came.

Note

We do not use the subject or phrase filter here as both are case sensitive (if you put the word 'invoice' here, mails including the word 'Invoice' in their subject/text will not cause a match as the 'i' is one time upper and one time lower case). Instead we use the Filter which we will set up after adding the next module.

Configuration:

Action Flows Module: Email

Action: Watch Emails

The configuration panel for an Email module within an Action Flow, showing various input fields to set up email filtering. The active configuration specifies a connection named My Google Restricted connection, monitors the INBOX folder for all emails, and

To face the possibility of having more than one attachment in a mail we need to set up an iterator to make sure every attachment is checked.The screenshot on the right shows how this module has been configured.

Configuration:

Action Flows Module: Flow Control

Action: Iterator

Iterator module settings with array configure to Attachments.

Set up a filter between the mail module and the iterator for with a throughput of mails which contain the word invoice either in their subject or text. The screenshot on the right shows how this filter has been configured.

Note

It is important to take the condition 'contains' which is case insensitive to make sure differences in upper or lower case letters are ignored.

Screen for setting up filter for mails.

To have more specific places to save the invoices in we want to create a Folder for each sender where we collect all the invoices we got from them. To do this we choose the create a Folder module. and

New Folder Name: 'Sender name' item from the Email module

same name handler: 'End with the error'. (This iscrucialfor the AF to work properly.)

Configuration:

Action Flows Module: OneDrive

Action: Create a Folder

OneDrive module settings screen

Set up a filter between the iterator and the OneDrive module with a throughput of attachments/files which contain the word invoice in their name. The screenshot on the right shows how this filter has been configured.

Note

It is important to take the condition 'contains' which is case insensitive to make sure differences in upper or lower case letters are ignored.

Settings for Set up a filter between the iterator and the OneDrive module with a throughput of attachments.

We are now getting to the part where we split our Action Flow without a Router. But How is this possible? One of the two routes is an Error handler and the other one is the normal route which is executed when the module before doesn't fail. If the model before fails this means that we already have a folder with the defined name (we defined that in 4. Create a Folder) and do not want to add the same folder again but upload the invoice in that folder. That's why we use as an error handler the Update a file module.

Action Flow for the Parse Email module in which the module's output is being routed to different Upload invoice modules.

Right click on the 'create a folder' module and choose the option 'Add error handler'. Add the 'Upload a file' module and set it up as in the screenshot.

Enter(Folder Location ID & Path): Folder Location Path (this is important to be able to find the right folder by name)

Folder: choose the item 'Sender name' from the mail module (→ we tried to set up a folder with that name which already existed, so we can access it like that)

Source file: Map (this will give us the possibility to change the naming of the file/invoice and make it unique)

File Name: We chose to construct the name out of the mails date and the original file name. Choose a name structure you want but make sure it will be unique!!

{{formatDate(1.date; "YYYY.MM.DD")}}_{{3.fileName}}

Data: data item of the iterator

Same name handler: set it to 'End with the error' as renaming the incoming file will lead to saving it outside the folder. Thus it is crucial to have unique file names.

Configuration:

Action Flows Module: OneDrive

Action: Upload a File

OneDrive module settings

To make it as easy as possible just right click on the error handling module created before and clone and connect it to the 'create a folder' module. The only thing you should change is

Folder: Name item of the 'Create a folder' module

Configuration:

Action Flows Module: OneDrive

Action: Upload a File

The configuration panel for an OneDrive module within an Action Flow, showing the setup for file uploads. The module uses a Microsoft connection configured to target My Drive, dynamically maps the folder path via a Name variable, maps the source file from

Related topics