I’m looking for some help with a flow I’m working on, it essentially takes emails in via SMTP and then pushes them to an API, I’ve got it working with the text payload of the message but now need to figure out how to include any possible email attachments.
Could someone please point me in the right direction?
Thanks
The email node's help tab gives you all the information you need.
Can you be more specific on what issue you are having ?
From the node's help tab :
Any attachments supplied in the incoming email can be found in the msg.attachments property. This will be an array of objects where each object represents a specific attachments.
As you noticed the body of the email is in msg.payload
any attachments should be in msg.attachments
add a Debug node after your email node and set it to show Complete msg object
to see the full msg structure.
As you can see the attachments portion at the bottom, I need to somehow perform a foreach and store it in a variable and place it within attachments =
I've had a rough go at it and have come out with something like this:
var attachments = ;
function addAttachments() {
msg.attachments.forEach(attachments => {
attachments.push({
'@odata.type': "#microsoft.graph.fileAttachment",
name: msg.attachments.filename,
contentType: msg.attachments.contentType,
contentBytes: msg.attachments.content,
});
})}
I'm sure you'll tell me I'm way off, but any help is greatly appreciated
I'm quite new to JS....historically more of a PowerShell man, but hey we all have to learn somewhere.