gpt4 book ai didi

读取 R 的电子邮件附件

转载 作者:行者123 更新时间:2023-12-04 17:47:18 29 4
gpt4 key购买 nike

我正在使用 R 阅读 Outlook 附件。我的引用在这里:Download attachment from an outlook email using R

这是我的电子邮件的截图:

enter image description here

这每天都会发送给我。

当我尝试提取此附件时,我是这样做的:

install.packages('RDCOMClient')
library(RDCOMClient)
outlook_app <- COMCreate("Outlook.Application")
search <- outlook_app$AdvancedSearch(
"Inbox",
"urn:schemas:httpmail:subject = 'DDM Report #107047216 : \"Nick_ACS_Brand_All_FloodLights\" from Nicholas Knauer'"
)


results <- search$Results()
results$Item(1)$ReceivedTime() # Received time of first search result
as.Date("1899-12-30") + floor(results$Item(1)$ReceivedTime()) # Received date

for (i in 1:results$Count()) {
if (as.Date("1899-12-30") + floor(results$Item(i)$ReceivedTime())
== as.Date("2017-12-17")) {
email <- results$Item(i)
}
}

attachment_file <- tempfile()
email$Attachments(1)$SaveAsFile(attachment_file)
data <- read.csv(attachment_file, skip = 10)

在我运行 results$Item(1)$ReceivedTime() 之后,出现了这个错误:

<checkErrorInfo> 80020009 
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352567
Error: Exception occurred.

知道如何解决这个问题吗?

谢谢!

最佳答案

尝试在保存为结果,和 results$Item(1)$ReceivedTime()。我认为这中间需要时间来处理。

results <- search$Results() # Saves search results into results object

Sys.sleep(5) # Wait a hot sec!

results$Item(1)$ReceivedTime() # Received time of first search result

as.Date("1899-12-30") + floor(results$Item(1)$ReceivedTime()) # Received date

# Iterates through results object to pull out all of the items
for (i in 1:results$Count()) {
if (as.Date("1899-12-30") + floor(results$Item(i)$ReceivedTime())
== as.Date(Sys.Date())) {
email <- results$Item(i)
}
}

关于读取 R 的电子邮件附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47857087/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com