# Save email attachments to Nextcloud

**URL:** <https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090>\
**Category:** General\
**Created:** [21 December 2024 15:59 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090 "2024-12-21T15:59:13Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 December 2024 13:20 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/21 "2024-12-24T13:20:45Z")

</div>

What is in msg.filename and msg.folder?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 December 2024 13:34 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/22 "2024-12-24T13:34:09Z")

</div>

The reason I am asking about msg.filename and msg.directory is that you said you had tried using them and it didn't work. I want to see your attempt to use them to solve your problem.

---

<div class="post-metadata">

**Author:** ![tty6747fg8](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tty6747fg8](https://discourse.nodered.org/u/tty6747fg8)\
**Post date:** [24 December 2024 13:36 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/23 "2024-12-24T13:36:15Z")

</div>

`undefined`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df3d543d22e2e70315bbd61fb1e177f114d77f89.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/15cbd7f1803f7246e472c33fab1644ebf83a9ed2.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 December 2024 13:38 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/24 "2024-12-24T13:38:03Z")

</div>

You have to save the file and then tell the node where it is, using those message properties.

---

<div class="post-metadata">

**Author:** ![tty6747fg8](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tty6747fg8](https://discourse.nodered.org/u/tty6747fg8)\
**Post date:** [24 December 2024 13:43 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/25 "2024-12-24T13:43:13Z")

</div>

write file node does nothing even if i set file path to /tmp/email.eml

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 December 2024 13:47 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/26 "2024-12-24T13:47:51Z")

</div>

I will try again. Feed the message that you are passing to the nextcloud node into a debug node set to Output Complete Message, and show us what that shows in the debug pane of the browser. Please try and provide the information that is asked for, not just what you think we need to see, but actually what we ask for. We cannot help if you do not provide the information.

[Edit] This is for your attempt to use msg.folder and msg.filename of course.

---

<div class="post-metadata">

**Author:** ![kitori](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kitori](https://discourse.nodered.org/u/kitori)\
**Post date:** [27 December 2024 14:18 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/27 "2024-12-27T14:18:13Z")

</div>

I Upload some PDFs to a nextcloud, not with the nextcloud node, but via dav2fs. So i mount the webdav folder directly in the filesystem and them just use the File node to save the File.

---

<div class="post-metadata">

**Author:** ![tty6747fg8](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tty6747fg8](https://discourse.nodered.org/u/tty6747fg8)\
**Post date:** [31 December 2024 19:07 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/28 "2024-12-31T19:07:10Z")

</div>

> [@Colin](#):
>
> Please try and provide the information that is asked for, not just what you think we need to see, but actually what we ask for

what did you ask for? u aked for msg.filename and msg.directory and i provided the out for those, claiming that i provide them is a lie

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 December 2024 20:38 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/29 "2024-12-31T20:38:08Z")

</div>

> [@tty6747fg8](#):
>
> what did you ask for?

I asked:

> [@Colin](#):
>
> Feed the message that you are passing to the nextcloud node into a debug node set to Output Complete Message, and show us what that shows in the debug pane of the browser.

Where have you done that?

You previously showed that msg.folder and msg.filename were undefined, but I assume that you have now changed that and are setting them to valid strings. If you feed the message into a debug node and show us what you are now sending then we may be able to say what is wrong.

---

<div class="post-metadata">

**Author:** ![tty6747fg8](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tty6747fg8](https://discourse.nodered.org/u/tty6747fg8)\
**Post date:** [5 January 2025 04:53 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/30 "2025-01-05T04:53:03Z")

</div>

man like i said here [Save email attachments to Nextcloud - #19 by tty6747fg8](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/19) the email is not fetched in full there is no attachment to get to Nextcloud and the node setup is

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/9/c9f8b8a9924db6e29f3af3b70b67ebcf46b0ba96.png)

---

<div class="post-metadata">

**Author:** ![tty6747fg8](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tty6747fg8](https://discourse.nodered.org/u/tty6747fg8)\
**Post date:** [5 January 2025 09:39 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/31 "2025-01-05T09:39:39Z")

</div>

i decided to give up on this i cant make it work

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [5 January 2025 09:43 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/32 "2025-01-05T09:43:09Z")

</div>

> [@tty6747fg8](#):
>
> the email is not fetched in full

I think you are saying that Node-red is only fetching a small fraction (17000 out of 500000 characters) of the email attachment.

I am not sure your little flow inject - email-in - debug can demonstrate this satisfactorily considering (as I said above), the debug output can be truncated for large messages.

Perhaps instead of this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b649900a274b9798579fd443cdcc9262a59074d.png)

You could prove the assertion with a flow like this (checking the size of the file)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d17d33cac39e51a932a4b7ad15672b7d13d63f56.png)

Or this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/4161668724de680de84cd932ee758db69e7f87b4.png)

(where the function is something like this:)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/91f2b265908cbc7e7eb2e7cf57235c9f8ac9cc05.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 January 2025 10:12 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/33 "2025-01-05T10:12:16Z")

</div>

Attachments is normally a array of objects.

I write incoming email attachment to a email directory using a split node.

```auto
[{"id":"1a88371a3c31917d","type":"inject","z":"667cec54c048503c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":940,"wires":[["b0baa5fadfdad440"]]},{"id":"b0baa5fadfdad440","type":"e-mail in","z":"667cec54c048503c","name":"","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"autotls":"required","port":"993","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","box":"INBOX","disposition":"None","criteria":"UNSEEN","repeat":"300","fetch":"trigger","inputs":1,"x":430,"y":940,"wires":[["058e40b95da4b614"]]},{"id":"058e40b95da4b614","type":"split","z":"667cec54c048503c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"attachments","x":550,"y":940,"wires":[["81a0633ac4e1f980"]]},{"id":"81a0633ac4e1f980","type":"change","z":"667cec54c048503c","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"\"/storage/documents/email_attachments/\" & $$.attachments.filename","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"attachments.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":940,"wires":[["724356920e77f41b"]]},{"id":"724356920e77f41b","type":"file","z":"667cec54c048503c","name":"","filename":"filename","filenameType":"msg","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":860,"y":940,"wires":[["c0a50bb0d49aec5e"]]},{"id":"c0a50bb0d49aec5e","type":"debug","z":"667cec54c048503c","name":"debug 2579","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":980,"wires":[]}]

```

 ![chrome_screenshot_5 Jan 2025 10_11_05 GMT](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5be8793027332afe51974733ff6c23da21268549.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 January 2025 10:12 UTC](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090/34 "2025-01-19T10:12:52Z")

</div>

Closed on 19 January 2025 10:12 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/save-email-attachments-to-nextcloud/94090.md?page=1)
