我正在努力定义一个适当的mime类型,同时试图将一个文件附加到一个字母上。我正在用png-映像测试这个功能,但最终我需要附加一个pdf。
library(gmailr)
test_email <- mime(
To = "mymail@yandex.ru",
From = sender_account,
Subject = "this is just a gmailr test",
body = "Can you hear me now?") %>%
attach_file(file = "health.png", type = "image/png")
send_message(test_email)得到这样的东西而不是附加的文件:
Can you hear me now? --29c4c91341434848f627ac9c696d9ed9--
我做错了什么?
发布于 2018-03-16 13:15:33
在此讨论这一问题:
https://github.com/jimhester/gmailr/issues/60
如果身体仍然包含--数字-字符串是可以接受的,那么下面的解决方案对我是有效的:
import(gmailr)
msg <- "This is the message body.\n\n"
email <- mime(
To = "to@domain.com",
From = "from@domain.com",
Subject = "Important subject",
body = msg)
email <- attach_part(email, msg)
email <- attach_file(email, file = "att1.txt", type = "text/plain")
email <- attach_file(email, file = "att2.txt", type = "text/plain")
email <- attach_file(email, file = "att3.pdf", type = "application/pdf")
send_message(email)发布于 2019-09-05 14:21:12
下面讨论一下:这里现在是固定的。您需要将gmailr更新为1.0.0及更高版本,更新代码如下
pkgload::load_all("~/p/gmailr")
write.csv(iris, "iris.csv")
gm_mime() %>%
gm_from("email@foo.com") %>%
gm_to("email@bar.com") %>%
gm_subject("I bought you") %>%
gm_text_body('Some flowers!') %>%
gm_attach_file("iris.csv") %>%
gm_create_draft()许多函数名都是通过添加'gm_‘来更改的(例如,mime现在是gm_mime ),但是请注意身份验证,这些函数的变化更大。
https://stackoverflow.com/questions/46672659
复制相似问题