1

我想全部回复 Outlook 中的电子邮件(例如,下面电子邮件中的第一个对象),但无法协调如何创建新邮件对象并全部回复电子邮件中的第一个对象。

require(RDCOMClient)
require(tidyverse)
OutApp <- COMCreate("Outlook.Application")
search <- OutApp$AdvancedSearch("Inbox", "urn:schemas:mailheader:date > '2020-12-7 00:12:30'") # searches emails sent in the last few hours
results <- search$results()
emails <- purrr::map(seq(results$Count()), function(x) results$Item(x))

这些电子邮件将带有特定的属性,如唯一的 Outlook ID 等,但我不太确定从那里去哪里。

下面,我们可以创建一个 Outlook 项目,但是我们如何编辑该电子邮件并将其作为 ReplyAll() 路由到我们标记的特定电子邮件?

outMail = OutApp$CreateItem(0) # Object type 0 = mail item
outMail[["HTMLbody"]] = "Hi everyone in this email chain. I sent this with R. Crazy!"
*outMail$ReplyAll(???)* # What here? Eternal mystery

我运气好的另一个可能的选择是mailR 包,但不知道如何回复特定的电子邮件。

require(mailR)

send.mail(from = "myemail@acct.com", to = "listofrecpts@acct.com",
          subject = "Subject",
          body = "This is supposed to be a reply all...",
          html = TRUE, inline = TRUE,
          smtp = list(host.name = "10.24.3.5", port = 25),
           authenticate = FALSE, send = TRUE)

唉,我不知道如何将它指向 Outlook 中的另一个电子邮件对象,即使我有一个特定的指针/电子邮件 ID。

有什么建议吗?

4

1 回答 1

0

您需要从 Results 集合中检索特定项目并调用MailItem.ReplyorMailItem.ReplyAll而不是Application.CreateItem.

于 2020-12-07T21:34:21.073 回答