I have a script to send an email with mailR. So far so good. But when I want to add a folder as an attachment, then it won't send the mail (the script is fine and there's no error). The name of the file in my folder change every week, so the attachment has to be the folder name and then it must send the file in it.
My script:
Library(mailR)
sender <- "name@mail.com"
recipients <- c("name@mail.com")
send.mail(from = sender,
to = recipients,
subject = "Subject of the email",
body = "Test",
smtp = list(host.name = "abnabnabnn,
user.name = "nsankjdnkak",
passwd = "123456", ssl = TRUE),
authenticate = TRUE,
send = TRUE,
attach.files = ("\\\\ab01\\Users\\tinus\\Desktop\\Temp folder\\"),
debug = TRUE)
What am I doing wrong?
I tried and search, but no result
The parameter name kind of says it all: attach.files
expects the path to a file or a vector of paths to files, not a directory name.
?mailR::send.mail
: "A character vector of paths in the file system linking to files or valid URLs to be attached to the email (see details for more info on attaching URLs)"
Try:
Library(mailR)
sender <- "name@mail.com"
recipients <- c("name@mail.com")
send.mail(from = sender,
to = recipients,
subject = "Subject of the email",
body = "Test",
smtp = list(host.name = "abnabnabnn,
user.name = "nsankjdnkak",
passwd = "123456", ssl = TRUE),
authenticate = TRUE,
send = TRUE,
attach.files = list.files("\\\\ab01\\Users\\tinus\\Desktop\\Temp folder\\", full.names = TRUE),
debug = TRUE)