I can attach an excel file into outlook by RDCOMClinet package. but how can I show the excel worksheet content in the mail body by R? Assume there's a table and a graph are contained in a worksheet.
library(RDCOMClient)
## init com api
OutApp <- COMCreate("Outlook.Application")
## create an email
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = "name@email.com"
outMail[["subject"]] = paste0("Report ", Sys.Date() - 1)
# attach a file via its directory
dirs <- dir(getwd(), full.names = TRUE)
outMail[["Attachments"]]$Add(dirs)
# insert an excel worksheet from attachment or local drive
outMail[["HTMLBody"]] = ?
For the table part, you could do for example
I don't know of an option for the chart part. Maybe embed an Excel chart in an Outlook email and inspect the resulting HTML?