ronisbr / PrettyTables.jl

Print data in formatted tables.
MIT License
391 stars 38 forks source link

Support for HTML Emails #198

Closed baumgold closed 1 year ago

baumgold commented 1 year ago

Thank you for putting together this package. I'm trying to send a nicely formatted table (e.g. border, colors) via HTML Email. Unfortunately it appears that some email providers (e.g. Gmail) do not support proper CSS. The suggestions that I've gathered from Google seem to be to either use inline styles, or raw HTML without any CSS. I haven't found a way to do either with this package or any other Julia package. Any suggestions? Here's an example of what I'm trying to do. Thanks.

using DataFrames, PrettyTables, SMTPClient
df = DataFrame(A=1:4, B=["A", "B", "C", "D"])
table = pretty_table(HTML, df)
emailfrom = "someone@somewhere.com"
emailto = [emailfrom]
subject = "Test123"
body = get_body(emailto, emailfrom, subject, get_mime_msg(table))
opt = SendOptions(; username=emailfrom)
send("smtp.google.com", emailto, emailfrom, body, opt)
baumgold commented 1 year ago

It actually looks like the problem is that Gmail ignores the CSS because it's not enclosed in a head block. #199 to fix the bug.