0

Using the code below to pull a .csv file from Microsoft Outlook into R for routine data manipulation and keep getting the following error (specifically after running the results lines):

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

Similar posts in Stack Overflow suggested adding sys.sleep() to fix this issue, allowing the system adequate time to search through e-mail subjects. After adding sys.sleep() with various time frames (ranging from 5-50), I'm still getting this error. Any suggestions or advice?

#Load in dataset from e-mail
outlook_app <-COMCreate("Outlook.Application")
search <- outlook_app$AdvancedSearch(
"Inbox",
"urn:schemas:httpsmail:subject = 'Outcome Information to Date'"
)

Sys.sleep(5)

results <- search$Results()

Sys.sleep(5)

for (i in 1:results$Count()) {
   if(as.Date("1899-12-30")+floor(results$Item(i)$RecievedTime())
   == as.Date(strptime(Sys.time(),format="%Y-%m-%d"))) {
   email <- results$Item(i)
    }
}

attachment_file<-tempfile()
email$Attachments(1)$SaveAsFile(attachment_file)

#Save outcome data in a dataframe
outcomedata<-read.csv(attachment_file)
  • Curiously, did code ever work and stops now? Try removing lines and advise which one raises error. – Parfait Jan 07 '19 at 19:21
  • Thank you for your response! The code has always shown this error. The error first appears when running the for() loop – hahannah22 Jan 08 '19 at 02:45

0 Answers0