Convert CSV to HTML table? - VisualCron - Forum

Community forum

jrtwynam
2019-04-08T17:59:21Z
Hi,

I've been using the SQL task quite a lot in my jobs, because much of what I need to do involves getting data from an Oracle database. Most of the time, I just need to loop through the results and do something with them, but today I was creating a job where all I want to do (for now) is query the database and email me the results. Of course, doing just that is relatively easy, but I'd like the results to be in a user-friendly format such as an HTML table within the email. I've done stuff in other jobs where I've looped through the results and manually constructed some HTML to nicely display them in the final email, but I'm wondering if there's an easier (i.e. built-in) way to do that within VC. Something that allows for some level of formatting, similar to the "Excel - Create" task where you can specify the columns, their data type, text alignment, etc. I'd like to be able to specify things like border style, font, font weight, back colour (separate for header row and body), etc.

Right now, the only thing I can think of is to write a generic job, maybe using a .NET task and some job variables, to do this. I could pass my CSV data into this job, have it process it and store the result in a job variable, and then have the initial job read the value from that job variable. This seems like an unnecessarily complicated way to do this though, not to mention the fact that I'm not sure how it would react if two different jobs are calling this job at the same time.

Any ideas?

Thanks.
thomas
2019-04-08T20:01:29Z
There is no built in way to do this. One of the problems is that different email clients handle html differently. Outlook for example only understands a subset of the html spec, and I assume other clients have their own quirks. You have to write code that works for you email client.

We have written a .NET assembly that handles this for us. We pass in the output from vc, the separator and a title. It works reasonably well. There are no problems if different jobs call this assembly at the same time.
Scroll to Top