How to Parse Attachments from Incoming Email and Automatically Split Attached PDF into Separated Pages using PDF.co and Make
In this tutorial, you will learn how to set up Make and PDF.co to receive and automatically extract the PDF attachments from incoming emails and split these PDF attachments into individual PDF pages. Then you will learn how to add uploading of generated PDF files into online storage like Dropbox or Google Drive.
You will need the following modules to set up and connect:
- Webhooks (in Mailhook mode that will intercept incoming emails)
- Flow Control (in Iterator so it will take multiple attachments and we can process each attachment separately)
- PDF.co PDF Split module (to process every attachment received)
IN THIS TUTORIAL
Step 1: Set Up the Webhooks Module with a Custom Mailhook Trigger
Click on the Add button to Add a hook and copy the generated address to set as your email forwarding address.
Step 2: Add the Flow Control Module and its Iterator Function
It will go through the array of attachments and will call the next module for every attachment. Please select Attachments[] in the Array field.
Step 3: Add the PDF.co Module and Select “Split a PDF”
Kindly select the Split a PDF function so we can split the PDF attachments.
- In the Input File field, select Upload a File. It means we are putting an input file into PDF.co instead of input Url.
- In the Source file field, choose Flow Control – Iterator. The Flow Control – Iterator is holding a single PDF attachment extracted from email.
- In the Pages field, enter the page numbers, for example, 1,1,1,1. It means to take the very first page and will create four different pdf files. We can set page ranges here as well, for example 1-2`.
- In the 2nd Source file field, select Flow Control – Iterator. This instructs PDF.co to take a single attachment from the Iterator module.
Step 4: Test the Configuration
We are now ready to test our configuration. Kindly click on the Run button to see the result.
Great! We have successfully set up our modules. In the Webhooks output, you’ll see the details of the received email.
Step 5: See the PDF Attachment File Name
In the Iterator output, you’ll find the filename of the PDF attachment that came with the email.
Step 6: See the Array Generated for the Split PDF Pages
And in the PDF.co output, you’ll see the DataAsArray[] array generated for the PDF attachment’s split pages. This array contains pdf files generated by PDF.co PDF Splitter:
Step 7: Steps for Automatically Uploading Generated PDFs to Online Storage
Now if you want to automatically upload these generated PDF files to online storage like Dropbox or Google Drive, just add another
Flow Control – Array Iterator” that will go through DataAsArray[] array and will call the next module one by one for each item in the array.
Now add new Flow Control – Array Iterator and set DataAsArray[] from PDF.co as input:
Finally, connect Flow Control – Array Iterator to Dropbox (or another online storage)
Step 8: Targeted Result
Here is the final scene you should have:
The final scenario can handle emails with multiple attachments and then can process every single attachment, split attachment into multiple PDF files and upload every single PDF file into online storage. Here is how it works, step by step:
- “WebHooks – Custom Mailhooks” module accepts emails with attachments;
- It generates Attachments[] array that contains one or more attachments from incoming email;
- “Flow Control – Array Iterator” goes through this Attachments[] array and calls PDF.co module for every single attachment in it;
- “PDF.co – Split a PDF” module splits input pdf attachment into multiple PDF files and returns DataAsArray[] array that contains generated pdf documents;
- Another “Flow Control – Array Iterator” module goes through DataAsArray[] array and calls Dropbox module for every single PDF file from DataAsArray[]
- Dropbox module uploads every single PDF file generated by “PDF.co – Split a PDF” module;
In this tutorial, we learned how to set up Webhooks to receive incoming emails. We configured the Iterator to get the PDF attachments from the previous step. And most of all, we learned how to use the Split function in PDF.co to split PDF pages into individual PDF documents and then how to automatically upload pdf files generated by PDF.co to online storage like Dropbox or Google Drive.