Question Regarding Email Node

Hi everyone,
I am starting out with n8n (been using it for a week now). I am trying to create a simple workflow composed of a Cron node to be executed every 30 minutes and it’s triggering a Function node which in turn triggering a Function Item node. The results are being stored into a Set node and then i want to send an email message at the end of the workflow with all the data from the Set node. Currently it’s sending one email message per line of data. My question is…how can i send one email message for all data accumulated into a Set node?

Best regards and thank you in advance.

Hey @pam!

Welcome to the community :sparkling_heart:

That is expected behavior. Based on the number of items returned by the previous node (in your case Set node), the next node gets executed. For example, if the Set node returns 10 items, the Send Email node will get executed 10 times. In such a case, you would have to transform the data into a single item. You can reference the code snippet here: JavaScript Code Snippets | Docs

Hope this helps :slight_smile:

Hi @harshil1712 !

Thank you so much for your prompt reply! I haven’t quite understood where i need to perform this kind of transformation? I mean…how to return an array of JSON?

Please bear with me i am still trying to understand!

Best regards.

Hey @pam,

I would add a Function node after the Set node to combine the data into a single item. I would then reference this data in the Email node.
I gave a talk on the data structure in n8n at our community meetup. This video might help you understand the data flow in n8n better: Data Structures in n8n by Harshil Agrawal - YouTube

If you can you share your workflow, I can reproduce the scenario and provide you the solution. Please replace any sensitive data with dummy data. (You can this out to understand how you can share your workflow: How can I contribute? | Docs)

Hi @harshil1712,
thanks again for your quick reply! If you don’t mind, let me play a bit with the information you gave me and i will let you know of the outcome! In case it’s too hard for me to solve i will reach out to you and provide the workflow. Don’t worry about the data…they are not sensitive! I always want to try and solve something by myself instead of just give it to someone else to do it for me! :slight_smile:

Best regards and really appreciate your kind help!

1 Like

Hey @pam,

That’s sounds a lot like me! Feel free to keep us updated here :slight_smile:

I am more than happy to help out!

Hi @harshil1712,
i am definitely missing something here! My output of the Function node is the following:

[Array: [{"json":{"SiteName":"Nikaia","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Kalithea","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Akropoli","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Kipseli","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Zografou","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Nea Xalkidona","SyncStatus":"SUCCESS","ErrorDetails":{}}},{"json":{"SiteName":"Peiraias","SyncStatus":"SUCCESS","ErrorDetails":{}}}]]

I just wanted to get the raw values from the Function node into my Email node. When my Email node gets executed i am getting an error message about crashing for unknown reason.

Best regards.

Hi @pam,

Any chance you can export your workflow to share, It might make it a bit easier to have a poke and see what is going on.

When you export it if you open the file in a text editor you can remove anything confidential.

2 Likes

Hey!

Are you getting error messages? Also, is it the Email node that crashes or is it the Function node.

A quick tip: Since I want to refer to all the values in a single email, I would use the Function node to create the message and pass it on to the Email node.

FYI, we’re going to release a node in the next couple of weeks that will allow you to do this easily. It will be called the ‘item list’ node.

1 Like

Good morning everyone!

Firstly let me thank each and everyone of you that took their time in answering my question and gave me even troubleshooting tips! I just wanted to let you know that i have managed to get the job done using @harshil1712 tip in concatenating all my data into a big String. What i was trying to do initially (with no success) is to assign as a text of my email message the “Raw Data” coming out of the Function node. I don’t know the “why” but that was the reason of my error message from the Email node.

I will try to explore n8n a bit more to become more familiar and then see what i can also contribute to the source code!

Best regards.

Hey @pam,

Good morning!

I am happy that we were able to help you and get your issue resolved :slight_smile:

Can you share your final workflow here? This will help other members that have the same issue find the solution easily!

I would also suggest you take the Beginner’s Course. It will help you learn more about n8n and give you more insights - Courses | Docs

Have fun :tada:

1 Like