I am using PS to import a csv, convert it to HTML, then send it in an email. It all works but Gmail ignores tags, so I cannot use CSS, and I cannot figure out how to do inline styling in PS.
All I want to do at this point is provide some padding to make the HTML more readable.
It basically comes out in the email in table format but not very readable. I would like to add some padding to the text and maybe even BOLD the column names. Everything I try just makes the table disappear from the email, as it is not being rendered past Gmails preprocessor.
Have you looked at our HTML Reporting free ebook (eBooks page)? It might not be exactly what you want, but you can certainly look at the technique and see if you can do something similar.
I did have a quick look and while it covers exporting to HTML using a lot of CSS, I cannot use CSS as this HTML is going straight into an email client that ignores style tags.
Looking at my code above, and comparing with the stackoverflow link in my reply, would you have any suggestions of how to write that?
You’ve got two basic methods. The first is to simply replace the generic tags with tags that have style applied. The second is dynamically creating the table by stepping through the data:
If I un-comment $finalHTML | Out-File “c:\folder\filez.html” on line 28 - it spits out an html file that looks EXACTLY how I want the body of the email to look.
When I try to $smpt.Send($finalHTML), instead of just Out-File, I get an error:
'Cannot find an overload for “Send” and the argument count: “1”.
When I $smpt.Send($message), the body converts to HTML and sends the email without error, but none of the $finalHTML is applied.
I feel like I am close, and if I am thinking correctly, I should be able to $smpt.Send($finalHTML) the same way I can Out-file it and get the same result in email that I get in the out-file?
The example I gave was just showing you the results in a browser. Make sure you add the beginning tag (e.g. less than) in the replace like my example above to only replace the beginning tag in the html. Take a look at the code below and see if that works for you: