Reputation: 161
I want to send data.frame data in body of email using gmailR. I tried htmlTable for the same. msg = htmlTable(data,rnames=FALSE)
html_bod <- paste0("<p> This is a test email. </p>", msg)
# sending mail
use_secret_file("/Users/abhishekgupta/Downloads/gmailR.json")
msg = htmlTable(data,rnames=FALSE)
html_bod <- paste0("<p> This is a test email. </p>", msg)
# sending mail
use_secret_file("/Users/abhishekgupta/Downloads/gmailR.json")
test_email <- mime(
To = "[email protected]",
From = "[email protected]",
Subject = "Data City Wise",
body = html_bod,
html =TRUE)
send_message(test_email)
Upvotes: 2
Views: 1320
Reputation: 6813
You can use html_body()
instead of the body
argument.
Load the packages:
library(gmailr)
library(tableHTML)
Create an HTML table using tableHTML
:
msg = tableHTML(mtcars)
Add a paragraph before the table:
html_bod <- paste0("<p> This is a test email. </p>", msg)
Create a MIME
message and send it:
mime() %>%
to("[email protected]") %>%
from("[email protected]") %>%
subject("Data City Wise") %>%
html_body(html_bod) %>%
send_message()
This is how the email looks like in gmail:
Upvotes: 8