有谁知道是否可以通过Outlook在R中发送电子邮件.sendmailR的所有示例都使用gmail服务器.我不能这样做.有任何想法吗?
谢谢!
我正在尝试使用htmlTable包将数据帧转换为 html 表,然后RDCOMClient通过附加 html 表作为电子邮件正文,使用 Microsoft Outlook 作为使用包的电子邮件客户端发送电子邮件。我是 HTML 编码的新手,所以我不太熟悉如何使用 HTML 标签格式化表格。下面是我正在尝试做的一个例子。
# Library to send email from Microsoft Outlook
library(RDCOMClient)
# Library to create HTML table
library(htmlTable)
# Reading data from inbuilt 'mtcars' dataset
x <- head(mtcars)
# Create HTML table
y <- htmlTable(x,
rnames = FALSE,
caption="This is from htmlTable package",
align = paste(rep("c", ncol(x)), collapse = "|"),
align.header = paste(rep("c", ncol(x)), collapse = "|"))
# add the table as body of the email …Run Code Online (Sandbox Code Playgroud) 我可以通过 RDCOMClinet 包将 Excel 文件附加到 Outlook 中。但是如何通过R在邮件正文中显示excel工作表内容?假设工作表中包含一个表格和一个图形。
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"]] = ?
Run Code Online (Sandbox Code Playgroud)