I have successfully converted the dataset to excel and sending that through Email this works fine. Now customer is expecting the Table should appear in the Email body itself. So I have used system.dataset.dataSetToHTML instead of system.dataset.dataSetToExcel to get the report. Now the HTML report is appearing as attachment but how to display this table in Body itself.
data = Sql query data
report_data = system.dataset.dataSetToHTML(1,data,"TurnOverReport")
body = report_data
recipients = "test@mamil.com"
system.net.sendEmail(smtpProfile="test@domain.com",fromAddr="test@domain.com",subject=subject,body=body,to= recipients)
sendEmail has an html parameter you can set to true (though it’s supposed to auto-detect it), and you might be able to get that to work, but bear in mind it will probably greatly increase the chances of inbox filters treating it as spam. You may need potential recipients to add the sender to a whitelist.
Tip: Set your "from" email address to something that will help trace it to its source if it starts spamming or creating problems. Something like scriptName.projectName@gatewayName.yourCompany.com will be a huge help to IT, etc.
I tried this once and because I didn’t do my company’s actual domain, it got reported for phishing a couple times (good on those employees, the trainings work!!)
Ended up keeping the company’s domain and all the needed info before the @
Now I am getting the HTML report in mail itself… this works If I want to change the color of the table column is there any possibility? I have to highlight some of the column data into different color
Example I am generating the shift data here I have a column name Line. So I want to differentiate the line name with color
You cannot use system.dataset.dataSetToHTML(), if you want a formatted table. You’ll have to manually get the table data, apply formatting or styles (using classes and the style tag) through loops.