omegahat / RDCOMClient

GNU General Public License v2.0
77 stars 34 forks source link

Can't Attach the RDCOMServer package need to create a generic COM object #8

Closed swraithel closed 6 years ago

swraithel commented 6 years ago

I've been working to look through my outlook emails and download the associated attachments. I've been able to complete every step except for the final step using the SaveAsFile.

folderName = "Inbox"

## create outlook object
OutApp <- COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")

#set folder to inbox
folder <- outlookNameSpace$Folders(2)$Folders(folderName)

# items (emails) in inbox
emails <- folder$Items

#example email with attachment
attach_name <- emails(1)$Attachments(2)$FileName()
#attachment exists
[1] "message.html"

#save attachment
emails(1)$Attachments(2)$SaveAsFile(glue("C:/Users/Seth_Raithel/Desktop/{attach_name}") )

The resulting error message is : Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘RDCOMServer’ Error in .COM(x, name, ...) : Can't attach the RDCOMServer package needed to create a generic COM object

I've tried installing RDCOMServer but it's not available R Version 3.4.1 Any recommendations or is this simply a compatibility issue?

duncantl commented 6 years ago

I suspect (but can't readily test) that you want to get rid of the class on the result of the call to glue(). e.g. ...$SaveAsFile(as.character(glue("C:/....{attach_name}")) or just avoid using glue() for this very simple task, e.g. file.path("C:/U...", attach_name) which is more sensible.

When RDCOMClient sees a class on an object, it tries to create a COM object.

I suspect that this will resolve the problem and remove the need for RDCOMServer. However, if you want RDCOMServer, you can build it from source if you have Rtools installed.

swraithel commented 6 years ago

Thanks for the quick reply. You were correct. Removing the glue class via the file.path function did the trick. Thanks for the help!