将附件从Outlook下载到R中 [英] Downloading attachment from Outlook into R

查看:150
本文介绍了将附件从Outlook下载到R中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Greg Thatcher对的回答(接受的回答)之后如何使用R RDCOMClient检索Outlook收件箱电子邮件?,我编写了一些代码来搜索我的收件箱并查找每天收到的电子邮件报告.代码以-

Following Greg Thatcher's answer (accepted answer) to How to retrieve Outlook inbox emails using R RDCOMClient?, I wrote some code to search through my inbox and find an email report I receive everyday. The code begins with -

library(RDCOMClient)

folderName = "Inbox"

OutApp = COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder = outlookNameSpace$Folders(1)$Folders(folderName)
emails = folder$Items

这在上周正常工作,但是系统通常在周末重新启动,现在却不工作,我也不知道为什么.我在代码段outlookNameSpace$Folders(1)$Folders(folderName)-

This was working last week but systems typically restart over the weekend, and now this is not working, and I have no idea why. I get an error on the second to last line in the code snippet outlookNameSpace$Folders(1)$Folders(folderName) -

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

但是,在尝试进行故障排除时,我遇到了使用我写出的R用a 从Outlook电子邮件中下载附件-

However, in trying to troubleshoot, I came across Download attachment from an outlook email using R using which I wrote out -

library(RDCOMClient)

OutApp = COMCreate("Outlook.Application")
search = OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject = 'Finding Memo - Specific Theme'")

这似乎可行,因为我在执行search$Results()$Count()时得到正确的号码.

This seems to work because I get the right number when I do search$Results()$Count().

问题是我无法(或不知道如何)将第二种方法用于我的流程,因为尽管电子邮件报告主题的开头部分保持不变,但结尾不断变化.第一种方法使我可以在电子邮件的主题上使用grepl().

Problem is I cannot (or do not know how to) use this second method for my process because the while the beginning part of the subject of the email report stays the same, the end keeps changing. The first method allows me to use grepl() on the subject of the emails.

如果有人可以帮助我了解导致第一种方法中断的原因,或者指导我修改第二种方法以与grepl()一起使用?

If someone could help me understand what is causing first method to break or guide me on modifying the second method to work with grepl()?

推荐答案

而电子邮件报告主题的开头部分保留 一样,结局不断变化.

while the beginning part of the subject of the email report stays the same, the end keeps changing.

您可以使用 %组合,然后:

You could use like in combination with % then:

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
search <- OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject like 'Finding Memo%'")
while (search$Results()$Count() == 0) TRUE 
for (x in seq_len(search$Results()$Count())) {
  print(search$Results()$Item(x)$Subject())
}

这在上周(...)工作正常,现在却无法正常工作. (...) 如果有人可以帮助我了解导致第一种方法的原因 打破

This was working last week (...), and now this is not working. (...) If someone could help me understand what is causing first method to break

由于它是不可复制的,并且您没有提供有关更改内容的信息,所以这将很困难.

Since it's not reproducible and you gave no info on what changed, this will be difficult.

这篇关于将附件从Outlook下载到R中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆