APTS 3 Posted November 12, 2015 Report Share Posted November 12, 2015 Can someone please explain the best method to be able to send a table in an email? Surely there must be an easy way to do this. I just can't figure it out. Thanks. Quote Link to post Share on other sites
deliter 203 Posted November 12, 2015 Report Share Posted November 12, 2015 add item to list(%mail, 1, "Don\'t Delete", "Global")add list to table as column(&myTable, 0, 0, %mail)connect to mail server("SMTP With SSL", "myeamil@mail.com", "myPassword", "smtp.mail.yahoo.com", 587) { save to file("{$special folder("Application")}\\myTable.csv", &myTable) send email("test@example.com", "test", "Plain Text", "eea", "{$special folder("Application")}\\myTable.csv", "", "")} in the connect to mail server wizard be sure to select the SMTP option at the top,and to also check SSL "Can someone please explain" This might not be the best solution,but it is a simple solution,save the csv file and then add the newly saved file as an attachment Quote Link to post Share on other sites
deliter 203 Posted November 13, 2015 Report Share Posted November 13, 2015 APTS said to me he was actually looking for a way of converting the CSV table to show in the email message body,Below is a function to convert your tables to HTML,you can click HTML on the send email,email type parameter to send a HTML instead of regular text on the options Ive no idea why but this runs VERY slow,it takes a few seconds to complete,and in the example below there are only 6 loops to complete,if someone has any idea why this is? **Edit I have just been made aware of the $html from table function,nice waste of time on this lol,I guess the CSS code I copied from w3schools.com was the only new thing added** clear table(&myTable) clear list(%mail) add item to list(%mail,"name","Don\'t Delete","Global") add item to list(%mail,"address","Don\'t Delete","Global") add item to list(%mail,"age","Don\'t Delete","Global") add list to table as row(&myTable,$table total rows(&myTable),0,%mail) clear list(%mail) add item to list(%mail,"John Doe","Don\'t Delete","Global") add item to list(%mail,"Texas","Don\'t Delete","Global") add item to list(%mail,34,"Don\'t Delete","Global") add list to table as row(&myTable,$table total rows(&myTable),0,%mail) clear list(%mail) add item to list(%mail,"John Doe2","Don\'t Delete","Global") add item to list(%mail,"Texas1","Don\'t Delete","Global") add item to list(%mail,324,"Don\'t Delete","Global") add list to table as row(&myTable,$table total rows(&myTable),0,%mail) comment("All Above is just creating a table for an example script") define $TabletoHTML(#Table) { create table from text(&myEmail,#Table) set(#rowP,0,"Local") set(#str1,"","Local") set(#tRows,$table total rows(&myEmail),"Local") set(#tColumns,$table total columns(&myEmail),"Local") loop(#tRows) { set(#columnP,0,"Local") set(#str,"","Local") loop(#tColumns) { if($comparison(#str1,"=",$nothing)) { then { set(#str,"{#str}<th>{$table cell(&myEmail,#rowP,#columnP)}</th>","Local") } else { set(#str,"{#str}<td>{$table cell(&myEmail,#rowP,#columnP)}</td>","Local") } } increment(#columnP) } set(#str1,"{#str1}<tr>{#str}</tr>","Local") increment(#rowP) } clear table(&myEmail) set(#emailTable,"<html><head><style>table, td, th \{ border: 1px solid green; \} th \{ background-color: green; color: white; \} table \{ border-collapse: collapse; \} table, th, td \{ border: 1px solid black; \} table \{ width: 100%; \} th \{ height: 50px; \} th \{ text-align: left; \} td \{ height: 50px; vertical-align: bottom; \} td \{ padding: 15px; \} </style></head><body><table>{#str1}</table></body></html>","Local") return(#emailTable) } set(#tableHTML,$TabletoHTML(&myTable),"Global") load html(#tableHTML) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.