I'm currently building a bit of code to search my emails for a particular subject and then search the body of the emails for some particular terms, then take comma separated data out of it. However I have now encountered an issue which I've never seen before, and that has only started appearing recently.
Whenever the code reaches:
inbox <- outlookNameSpace$Folders(6)$Folders("Inbox")
I get the following error:
<checkErrorInfo> 80020009
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352567
Error: Exception occurred.
Now I've seen people encounter similar errors around the place, but they seem to be dealing with sending emails rather than searching for particular emails.
I was wondering if anyone had any advice on how to fix this?
Full code:
library(RDCOMClient)
Fruit_1 <- "Apples"
Fruit_2 <- "Pears"
##Create vector to store searchables
searchf <- c(Fruit_1, Fruit_2)
## create object for outlook
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
search <- OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject = 'FRUIT QUANTITIES'")
inbox <- outlookNameSpace$Folders(6)$Folders("Inbox")
vec <- c()
get_vals <- function(report,searches) {
data <- read.table(text=report,sep=",")
colnames(data) <- c('key','value')
date <- data[grepl("date",data$key,ignore.case=T),"value"]
lst <- split(data$value,data$key)
c(list(date=date),lst[searches])
}
for (x in emails)
{
subject <- emails(i)$Subject(1)
if (grepl(search, subject)[1])
{
text <- emails(i)$Body()
print(text)
break
}
}