# Email logged file

**URL:** https://discourse.nodered.org/t/email-logged-file/19029
**Category:** General
**Created:** [11 December 2019 17:39 UTC](https://discourse.nodered.org/t/email-logged-file/19029 "2019-12-11T17:39:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![NPLPRS](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@NPLPRS](https://discourse.nodered.org/u/NPLPRS)
#### Post date: [11 December 2019 17:39 UTC](https://discourse.nodered.org/t/email-logged-file/19029/1 "2019-12-11T17:39:07Z")

</div>

Hi All,

I have node red collecting data from a USB serial port. The data comes in, gets a timestamp added to it and then sent onto a log file on the Raspberry Pi desktop.

I would like Nodered to then automatically email the stored log file every 6 hours to a pre-set email address. I can get Nodered to send emails just fine but cannot for the life of me work out how to send the log file!

Thanks for the help.

Nick

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [11 December 2019 19:08 UTC](https://discourse.nodered.org/t/email-logged-file/19029/2 "2019-12-11T19:08:41Z")

</div>

Well the info on the right should help you... it points to creating a msg.attachments array pointing at the file. A function like this

```auto
msg.attachments = [
    {   
        filename: 'yourfile.log',
        path: '/path/to/yourfile.log' 
    }
];

```

---

<div class="post-metadata">

### Author: ![NPLPRS](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@NPLPRS](https://discourse.nodered.org/u/NPLPRS)
#### Post date: [16 December 2019 10:59 UTC](https://discourse.nodered.org/t/email-logged-file/19029/3 "2019-12-16T10:59:21Z")

</div>

Thanks for the help! Still struggling though, i have no idea how to do this.

Do I put the function node you mentioned before or after log file node?

I cant believe its so hard to send an automatic email of a log file a few times a day!

Many thanks

Nick

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 December 2019 11:02 UTC](https://discourse.nodered.org/t/email-logged-file/19029/4 "2019-12-16T11:02:01Z")

</div>

after the file log node would be best.  
If you are able to share your flow file it would be easier to advise.

---

<div class="post-metadata">

### Author: ![NPLPRS](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@NPLPRS](https://discourse.nodered.org/u/NPLPRS)
#### Post date: [16 December 2019 15:06 UTC](https://discourse.nodered.org/t/email-logged-file/19029/5 "2019-12-16T15:06:06Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f7e775f513877056505b0f9214d5ca8a44678ad9.png)

---

<div class="post-metadata">

### Author: ![NPLPRS](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@NPLPRS](https://discourse.nodered.org/u/NPLPRS)
#### Post date: [16 December 2019 15:07 UTC](https://discourse.nodered.org/t/email-logged-file/19029/6 "2019-12-16T15:07:04Z")

</div>

Thanks - heres the pic.  
The function node in between the serial port and the log simply adds a timestamp.  
Thanks

Nick

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [16 December 2019 16:03 UTC](https://discourse.nodered.org/t/email-logged-file/19029/7 "2019-12-16T16:03:56Z")

</div>

I was thinking more the actual flow file

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…
