I’m looking for a node that can take in a MIME message and split this into an JSON object with subject, body, html, from, etc. as well as the individual attachments.
Basically, what I’m looking for is the IMAP Email node, but instead of waiting for a mail message, actively feeding the MIME message into this node.
And if this does not exist yet, would anybody be interested to help me develop such a node?
If I understood correctly I do not think you even need to create a node to do this. Just import Nodemailer in a function node (you need to set an env variable to be able to do so) and use the simpleParser method.
Hi @RicardoE105 , thanks and uh … since I’m relatively new to n8n, does this means that I’ve got to ad NODE_FUNCTION_ALLOW_EXTERNAL to the environmental variables (/.env) file? And that I that have to start with JavaScript code in the function node with
The only thing I haven’t figured out yet, is how to get the attachments. Since I’m a very simple FileMaker Developer and not used to hardcoding, I’m probably overlooking something very simple.
This is my code so far:
The TestMIME without attachments works fine, but the Test MIME with Attachment returns a whole lot of text. And if you want to change from Object to JSON, it hangs-up the system.
And this is the relevant section of the documentation from NodeMailer …
And I finally figured it out … with the help of some of the kind people in the n8n community as well as the apparently limitless amount of information in this forum.
My working workflow with simpleParser now looks as follow:
This workflow contains a separate branch for testing.
The whole concept is to feed in the MIME text of an email message which then gets converted to a JSON array with all the relevant data, such as from, to, date, subject, body, html, messageId and attachments. It also convert the attachment buffers into Base64encoded text.
I already build something in FileMaker year’s ago, but this has become so complicated that it is difficult to maintain.
Since I’m fairly new to n8n and still have to get my head around a few basic concepts, this flow may be more complicated than necessary. So please do not hesitate to give me feedback
After further implementation in my FileMaker workflow, I found out that I had not taken into account messages without attachments. Here’s the workflow that does: