我编写了一个R脚本,以便每天在预定时间创建邮件警报。当我手动执行代码时,它可以很好地工作,并且我可以立即收到电子邮件。但是,当我使用任务计划程序运行脚本时,它只是无法完成任务。
下面是我的代码,我的问题是分配任务或编写代码时我是否犯了一个错误?
library(mailR)
message1="hello"
message2="hello"
send.mail(from ="xxxxxx@gmail.com",
to = c("xxxxxx@gmail.com"),
subject = "Summary of stock performance",
#body =paste(message1,"\r\n",message2),
body = paste("<p> Overall </p>",message1,"<p>",message2,"<p>"),
#body = paste(message1,"\r\n",message2,"\r\n"),
#body="hello",
html = TRUE,
inline = TRUE,
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "xxxxxx", passwd = "xxxxxxx", ssl = TRUE),
authenticate = TRUE,
send = TRUE)