【问题标题】:How to attach two files when sending message to SMTP Server (emayili+Outlook)发送邮件到 SMTP 服务器时如何附加两个文件(emayili+Outlook)
【发布时间】:2021-12-01 18:35:03
【问题描述】:

我一直在设置 emayili 包以从我的 Outlook 帐户发送带有两个附件的电子邮件,但到目前为止我一直无法这样做。

代码如下(将电子邮件和密码替换为“aaa”和“bbb”以保护隐私/安全):

email <- envelope(
  from = "aaa@domain.com",
  to = "bbb@domain.com",
  subject = subject,
  html = body) %>%
  attachment('filename1.xlsx') %>%
  attachment('filename2.xlsx')

smtp <- server(host = "smtp.mailtrap.io",
        port = 587,
        username = "********",
        password = "*********")

smtp(email, verbose = TRUE)

当我运行代码时,我得到以下结果:

> smtp(email, verbose = TRUE)
Sending email to smtp.office365.com:587/.
Error: Request failed after 5 attempts
Run `rlang::last_error()` to see where the error occurred.
In addition: Warning messages:
1: In smtp(email, verbose = TUE) :
 ​ restarting interrupted promise evaluation
2: In f(...) : restarting interrupted promise evaluation
3: In f(...) : restarting interrupted promise evaluation
4: In f(...) : restarting interrupted promise evaluation
5: In f(...) : restarting interrupted promise evaluation

知道出了什么问题吗?

【问题讨论】:

    标签: r outlook smtp


    【解决方案1】:

    也尝试使用library(Microsoft365R)


     outl <- get_personal_outlook()
    
     #your code
     # using emayili to create an email with attachments
     ey_email <- emayili::envelope(
     text="Hello from emayili",
     to="user@example.com",
     subject="example emayili email") %>%
     emayili::attachment("mydocument.docx") %>%
     emayili::attachment("mydata.xlsx")
     outl$create_email(ey_email)
     #your code
    

    完整的手册你可以找到there

    【讨论】:

      猜你喜欢
      • 2016-02-09
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      • 2016-12-18
      • 2021-07-16
      • 2014-10-27
      • 1970-01-01
      • 2018-10-17
      相关资源
      最近更新 更多