# Simple report email

**URL:** <https://forum.inductiveautomation.com/t/simple-report-email/18934>\
**Category:** Ignition\
**Created:** [July 23, 2018, 4:18pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934 "2018-07-23T16:18:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikenna.nwaogu](https://avatars.discourse-cdn.com/v4/letter/i/e274bd/32.png) [@ikenna.nwaogu](https://forum.inductiveautomation.com/u/ikenna.nwaogu)\
**Post date:** [July 23, 2018, 4:18pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934/1 "2018-07-23T16:18:57Z")

</div>

I have been trying to send a report through email through a button even the simplest form hasn’t worked. I dont get any error and that’s the most annoying part of. Here is my simple code just as the manual

system.report.executeAndDistribute(path=‘reports/COfAReport’, action= “email”,  
actionSettings = {“to”:[“innwogu@jcomp.com”], “smtpServerName”:“10.14.22.50:25”, “from”:"proces@comp.com", “subject”:“Production Report”})

What am I doing wrong?

Also, is there a way to access pdf files saved in the gateway through the designer and client. Seems like when I used system.file functions, it is accessing the clients computer not the gateway. Thanks.

---

<div class="post-metadata">

**Author:** ![ikenna.nwaogu](https://avatars.discourse-cdn.com/v4/letter/i/e274bd/32.png) [@ikenna.nwaogu](https://forum.inductiveautomation.com/u/ikenna.nwaogu)\
**Post date:** [July 23, 2018, 4:40pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934/2 "2018-07-23T16:40:39Z")

</div>

I resolved this using another method. I sill need answer to second question. Thanks.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 23, 2018, 4:40pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934/3 "2018-07-23T16:40:52Z")

</div>

Check in the gateway logs (Gateway webpage -\> Status -\> Diagnostics/Logs).

> [@ikenna.nwaogu](#):
>
> Seems like when I used system.file functions, it is accessing the clients computer not the gateway.

That's correct - exposing the filesystem of the gateway to all clients would be rather dangerous. The usually recommended approach is to store generated .PDFs as binary data (BLOBs) in a database table. Then clients can simply run a SQL query and use the PDF viewer component's [`loadPDFBytes`](https://docs.inductiveautomation.com/display/DOC79/PDF+Viewer#PDFViewer-loadPDFBytes)

Another approach is to use [message handling/system.util.sendRequest](https://docs.inductiveautomation.com/display/DOC79/system.util.sendRequest) so that the client requests a particular report/filename, then a gateway message handler runs and response with a byte array using [`system.file.readFileAsBytes`](https://docs.inductiveautomation.com/display/DOC79/system.file.readFileAsBytes).

---

<div class="post-metadata">

**Author:** ![ikenna.nwaogu](https://avatars.discourse-cdn.com/v4/letter/i/e274bd/32.png) [@ikenna.nwaogu](https://forum.inductiveautomation.com/u/ikenna.nwaogu)\
**Post date:** [July 23, 2018, 4:43pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934/4 "2018-07-23T16:43:26Z")

</div>

Thanks a bunch. I thought there could be away to give some form of privilege to users in other for that. Any, the database idea is a good one. Thanks again.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [July 23, 2018, 4:48pm UTC](https://forum.inductiveautomation.com/t/simple-report-email/18934/5 "2018-07-23T16:48:57Z")

</div>

Do you have an SMTP profile set up already? It looks like you might be putting the IP address and port of your SMTP server in rather than the name of the SMTP profile.
