alec22
alec22

Reputation: 762

Strange InterfaceSupportsErrorInfo error - checkErrorInfo -2147352567 Error: Exception occurred

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
  }
}

Upvotes: 2

Views: 533

Answers (3)

alec22
alec22

Reputation: 762

Turns out the reason for the failure was R was running too many lines of code. Therefore the addition of a Sys.sleep(5) after the 'search' variable solved the problem.

So my code looks like:

search <- OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject = 'FRUIT QUANTITIES'")
Sys.sleep(5)

Upvotes: 2

Eugene Astafiev
Eugene Astafiev

Reputation: 49453

Try to replace the order of the following lines of code:

inbox <- outlookNameSpace$Folders(6)$Folders("Inbox")

search <- OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject = 'FRUIT QUANTITIES'")

The AdvancedSearch method of the Application class performs a search based on a specified DAV Searching and Locating (DASL) search string on a secondary thread. So, you should be aware that programmatically creating a large number of search folders can result in significant simultaneous search activity that would affect the performance of Outlook, especially if Outlook conducts the search in online Exchange mode.

In the code I didn't find how you handle the search results, but you may be interested in handling the Application.AdvancedSearchComplete event which is fired when the AdvancedSearch method has completed.

But if you need to search for items in a single folder (like in your code) you could used synchronous methods like the Find/FindNext or Restrict methods. You can read more about them in the following articles:

Upvotes: 0

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66341

Why are hardcoding the mailbox index (6)? If you need the default Inbox, use Namespace.GetDefaultFolder(olFolderInbox). If you need a particular mailbox, use its name rather than index.

Upvotes: 1

Related Questions