我的R Studio版本为3.4.3。 我在发送电子邮件给至少2个人(以后发送到100多人)时遇到问题。
例如:邮寄给一个人。这里一切都很好。这是代码:
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
to="a@outlook.pl"
outMail[["To"]] =to
outMail[["subject"]] = "Mail R Studio"
outMail[["body"]] = "body mail"
outMail$Send()
所以,我们将邮件发送给2个人。我这样做:
mailing_list <- data.frame(to = c('a@outlook.pl','a@outlook.pl'),
subject = c('Mail R Studio','Mail R Studio'),
body = c('Please, help me','Please, help me')
for (i in 1:nrow(mailing_list)) {
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = mailing_list[i,1]
outMail[["subject"]] = mailing_list[i,2]
outMail[["body"]] = mailing_list[i,3]
outMail$Send()
}
错误代码:
`[[<-`(` tmp `,“ To”,value = 1L)中的错误:
无法附加创建通用COM对象所需的RDCOMServer程序包 另外:警告消息: 在库中(包,lib.loc = lib.loc,character.only = TRUE,logical.return = TRUE,: nie ma pakietu o nazwie的“ RDCOMServer”
但是当我安装.packages(“ RDCOMServer”)时,反馈是:
install.packages中的警告:
软件包“ RDCOMServer”不可用(对于R版本3.4.3)
请帮帮我!谢谢
答案 0 :(得分:0)
library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]] = paste ( "samikar@cisco.com"
,"subhdas@cisco.com"
,"ragthumm@cisco.com"
,"snarasgo@cisco.com"
,"dmarwaha@cisco.com"
,"shrenaik@cisco.com"
,"ahabdelj@cisco.com"
, sep = ";", collapse = NULL)
outMail[["subject"]] = 'subject'
outMail[["body"]] = 'body'
try(outMail$Send())
答案 1 :(得分:0)
您的名为mailing_list的data.frame包含因素,而不是字符串。因此,您要从一个因素中分配一个值给outMail [[“ To”]]。该值是整数,在这种情况下为1L。所以那是错误的。就像上面的答案说的那样,制作这些字符串。使用
mailing_list <- data.frame(to = c(...), ..., stringsAsFactors = FALSE)
答案 2 :(得分:0)
请在 to 列表中用分号 (;) 分隔电子邮件,它应该可以正常工作。
示例: to="a@outlook.pl;b@outlook"