2

I'm trying to use the mailR package to send HTML tables through email. When I render the markdown file the tables look like this: enter image description here However, when I email it the tables lose the borders and look like this: enter image description here Is there a way to ensure that the borders appear in the email?

Here is the code I'm using.

---
title: "Email Test"
output: html_document
---

## Hello world!

```{r setup, include=FALSE, echo=FALSE}
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(kableExtra))

### Table 1:

```{r table1, include=TRUE, echo=FALSE, results='asis'}

head (mtcars, 10) %>% 
  rownames_to_column(var = "car") %>% 
  select (cyl, car, mpg, disp, hp) %>% 
  arrange (cyl) %>% 
  kable (escape = FALSE, 
         align = "clccc") %>% 
  kable_styling(c("bordered")) %>% 
  column_spec(1:5, color = "black") %>% 
  collapse_rows(columns = 1, valign = "middle") 


mailR:

library(rmarkdown)
library(knitr)
rmarkdown::render("Email_Test.Rmd")

library(mailR)

send.mail(from = "my.name@myorg.com",
          to = "your.name@myorg.com",  
          subject = "TEST EMAIL",
          html = TRUE,
          inline = FALSE,
          body = "Email_Test.html",
          authenticate = TRUE,
          smtp = list(host.name = "smtp.office365.com", 
                      port = xxx,
                      user.name = "my.name@myorg.ca", 
                      passwd = "xxxxxxxxxxxxx", 
                      tls = TRUE)
          )
GregRousell
  • 997
  • 2
  • 13
  • 23

0 Answers0