# sendEmail do not attach file

**URL:** <https://forum.inductiveautomation.com/t/sendemail-do-not-attach-file/6230>\
**Category:** Ignition\
**Created:** [April 15, 2013, 1:47pm UTC](https://forum.inductiveautomation.com/t/sendemail-do-not-attach-file/6230 "2013-04-15T13:47:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kramar](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@kramar](https://forum.inductiveautomation.com/u/kramar)\
**Post date:** [April 15, 2013, 1:47pm UTC](https://forum.inductiveautomation.com/t/sendemail-do-not-attach-file/6230/1 "2013-04-15T13:47:26Z")

</div>

Hello! I can`t attach files to sending message. an email is sent and received without error, but there are no attachments. I tried gmail and local server (hMailServer). What I do wrong? here is my code:[code]filepath=system.file.getTempFile(“txt”)  
system.file.writeFile(filepath,“this is tested file”)

subject=“Test”  
body=“this is to test mail send \n” + filepath + “\n”  
html=0  
attachmentName1=“ping.txt”  
attachmentData1=system.file.readFileAsBytes(filepath)  
[username1="test@192.168.1.51](mailto:username1=%22test@192.168.1.51)"  
password1=“test”

system.net.sendEmail(“192.168.1.51”,"test@192.168.1.51",subject,body,html,[“test@192.168.1.51”],attachmentName=[attachmentName1],attachmentData=[attachmentData1],username=username1,password=password1)[/code]

With best regards, Porev Alexander

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [April 15, 2013, 3:06pm UTC](https://forum.inductiveautomation.com/t/sendemail-do-not-attach-file/6230/2 "2013-04-15T15:06:45Z")

</div>

Hi kramar,

I think that your problem is with the sintaxis you used…

This code works in my script without error and sends two print screens by email:

[color=#0000FF]  
Window1 = system.gui.getWindow(“Month”)  
name\_window1 = “Month.png”  
system.print.printToImage(Window1,name\_window1)

Window2 = system.gui.getWindow(“Year”)  
name\_window2 = “Year.png”  
system.print.printToImage(Window2,name\_window2)

file\_Name1 = “Month.png”  
file\_Data1 = fpmi.file.readFileAsBytes(name\_window1)

file\_Name2 = “Year.png”  
file\_Data2 = fpmi.file.readFileAsBytes(name\_window2)

system.net.sendEmail(“xxx”,“xxx”,“xxx”,“xxx”,0,“xxx”,[file\_Name1,file\_Name2],[file\_Data1,file\_Data2])[/color]

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 20, 2013, 9:30pm UTC](https://forum.inductiveautomation.com/t/sendemail-do-not-attach-file/6230/3 "2013-05-20T21:30:10Z")

</div>

The problem looks like you wrote [tt]attachmentName=[attachmentName1][/tt] when it should be [tt]attachmentNames=[attachmentName1][/tt]
