我想将不同扩展名的文件附加到邮件中。我的一些 id 有 pdf 文件,有些有 excel 文件。所以我为这两种类型的文件生成了路径。但是当我附加文件时,它会给我一个错误 attach.files 必须链接到有效文件。这是正确的,该文件不存在。谁能帮助我。
在此处输入代码
data_send<-read.csv('/Users/vaibhav.chawla/Downloads/manual.csv')
smtp<-list(host.name="smtp.gmail.com",smtpPortSMTP=465,user.name="vaibhav@xxxx.com",passwd='xxxx',ssl=T)
i=1
for (i in i:nrow(data_send)) {
from <- "xxxxx"
to<-c(paste0(data_send$mail[i]))
cc<-c(paste0(data_send$amail[i]))
subject <-paste0("Summary May 01, 2020 to May 27, 2020")
body <-paste0("Hello")
filtetype <- c(".xlsx",".pdf")
path<-c(paste("/Users/vaibhav.chawla/Downloads/Excel/",data_send$id[i],filetype,sep=""))
mailSend<-send.mail(from=from,to=to,cc=cc,subject=subject,body = body,smtp=smtp,authenticate = T,send = T,html=T,inline = T,attach.files = c(path))
print(paste0(i,". Mail sent to ",data_send$id[i]))
}