R 脚本 (mailR) 文件夹中的所有文件作为附件

问题描述 投票:0回答:1

我有一个使用 mailR 发送电子邮件的脚本。到目前为止,一切都很好。 但是当我想添加文件夹作为附件时,它不会发送邮件(脚本很好并且没有错误)。 我的文件夹中的文件名每周都会改变,所以附件必须是文件夹名,然后必须发送其中的文件。

我的脚本:

Library(mailR)
sender <- "[email protected]"
recipients <- c("[email protected]")
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)

我做错了什么?

我尝试过搜索,但没有结果

r email attachment send
1个回答
0
投票

尝试:

Library(mailR)
sender <- "[email protected]"
recipients <- c("[email protected]")
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)

© www.soinside.com 2019 - 2024. All rights reserved.