【发布时间】:2020-07-06 00:29:19
【问题描述】:
我在 R 中编写了一个脚本,该脚本通过我在 Outlook 中的邮件来搜索确定的电子邮件。问题是每次脚本尝试访问我的电子邮件时,都会弹出一个窗口并请求许可。该脚本按预期工作,但进程减慢,因为我每次都必须在那里单击“允许”。 我已经读到可以允许程序在 Trusct Center 选项中进入我的 Outlook,但 Windows 版本太旧,无法通过这种方式修复。此外,由于这是一个共享服务器,我没有管理员访问权限,因此无法进行重大更改。 我读过其他类似的问题,但在 R 中没有,比如这个[Suppress Outlook pop-up allow access 或这个[How to supress the outlook pop up message while sending mails in PB8。 这是我的脚本:
library(RDCOMClient)
library(stringr)
#Folder in OutLook where to look for the emails
folderName = "Specific folder"
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder <- outlookNameSpace$Folders(1)$Folders(folderName)
folder$Name(1)
emails <- folder$Items
for (i in 1:emails()$Count()){
subject <- emails(i)$Subject() #Get the subject of the email
#If the subject of the email has an specific string print the body of the message
if (grepl("Subject to look for", subject)== TRUE){
body <- emails(i)$Body() # Here asks for permission
print(body)
}
}
有没有办法嵌入一段代码来避免这个弹出窗口或自动“点击”允许?
【问题讨论】: