data frame turns into a mess in an email with sendmail function

Hi R experts,

I tried to send a data table by "sendmail" in sendmailR package.
Here is my code:
library(xtable)
library(sendmailR)
employee <- c('John Doe','Peter Gynn','Jolie Hope')
salary <- c(21000, 23400, 26800)
outputf <- data.frame(employee, salary)

from <- "xxx1@xxx.com"
to <- "xxx2@xxx.com.tw"
subject <- "update"
body <-print(xtable(outputf,caption = 'a data table'),type='html',caption.placement = 'top')
mailControl=list(smtpServer="123",port=1)

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)

However, the output in the email is a mess (see below)
tr>

1 2019-06-19 2091 1283 3374 0.38 2318 <td

Could you please suggest a way to write a data frame in an email?
Thanks.

Best,
Veda

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.