blastula
blastula copied to clipboard
gt table not centered in email
Is there a way to center a table when sending a email? Using outlook client the table is left-align, however when rendering the email in the browser it looks fine.
reprex:
exibble_a <-
exibble %>%
dplyr::select(-c(fctr, date, time, datetime)) %>%
gt(rowname_col = "row", groupname_col = "group") %>%
fmt_missing(columns = everything())
exibble_a_html <- as_raw_html(exibble_a)
email <-
compose_email(
body = md(
c(
'## My email',
"This is my email. The table is not centered:",
exibble_a_html
)
)
)
email %>%
smtp_send(
from = "[email protected] ",
to = c("[email protected]"),
subject = "hello",
credentials = creds_key(id = "powerbigw")
)
Browser:
Outlook Client:
Hi, I´ve managed to hack this using block_articles
:
email <-
compose_email(
body =
blocks(
block_text(
md(
c(
'## My email',
"The table now looks centered but is weird in android:"
))
),
block_articles(
article(),
article(content = exibble_a_html), # is centered but looks weird in outlook android app
article()
),
block_text("Outside block_articles looks fine:"),
exibble_a_html # looks ok but not centered
)
)
email %>%
smtp_send(
from = "me@me",
to = c("me@me"
),
subject = "Hola",
credentials = creds_key(id = "id")
)
Which looks centered in the outlook client:
BUT now looks weird in the outlook android app 😢 : Clic for long picture
We will take a closer look at this later in the year (when we start working on blastula again). As a workaround, you can save the gt table as an image with gtsave()
, and it's not a bad option unless you need copy/paste ability.