我已经尝试了几种不同的方式来编写此代码,并不断遇到相同的错误。我不认为代码是问题,我想知道是否缺少RDCOMClient的功能。该功能正常工作,因为我已通过此发送了许多电子邮件。循环功能不起作用。
我只是试图遍历DataFrame的向量,并发送与其所遍历的电子邮件相对应的电子邮件。
(例如,应将电子邮件发送到email1,将电子邮件发送到email2,等等。]
test.df <- data.frame(
"email" = c("email1", "email2", "email3")
,"name" = c("name1", "name2", "name3")
)
mail_fun <- function(mail) {
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = mail
outMail[["subject"]] = "Project hours for next week"
outMail[["HTMLBody"]] = paste0("<p>Testing sending hours through R</>")
## send it
outMail$Send()
}
sapply(test.df$email, mail_fun)
这是我收到的错误:
[[<-
中的错误(*tmp*
,“至”,值= 2L):无法附加创建通用COM对象所需的RDCOMServer程序包另外:警告消息:在库中(包,lib.loc = lib.loc,character.only = TRUE,逻辑.return = TRUE,:
[[<-
中的错误(*tmp*
,“至”,值= 2L):无法附加创建通用COM对象所需的RDCOMServer程序包
test.df <- data.frame(to = c(...), ..., stringsAsFactors = FALSE)