0

I'm trying to apply both $list_attachments() and $download_attachment() to my outlook object but they return the same error. The code is straight forward:

email <- my_outlook$list_emails(n = 1)

email2 <- email$list_attachments()
Error: attempt to apply non-function

email2 <- email$download_attachment()
Error: attempt to apply non-function

Any ideas of what's going on?

iago nunes
  • 56
  • 9
  • What does `str(email)` show? Is it a list, NULL, or ...? – user20650 Jun 01 '23 at 11:50
  • It's a list @user20650 – iago nunes Jun 01 '23 at 12:05
  • 1
    okay. (by just looking at structure) I can reproduce errors with `em = list(a=1); em$fun()`. So you could try `email[[1]]$list_attachments()` (assuming that the structure of the list allows this / has just one level) . Otherwise, likely need a reproducible example, or t least more details on the objects structure. – user20650 Jun 01 '23 at 12:10
  • It worked, just had to put the level in the statement. Thank you! – iago nunes Jun 01 '23 at 12:17

1 Answers1

1

Thanks to @user20650's comment I've identified the problem. It's the structure of the object, which is a list. The level needs to be stated so the function can work with the right element, like so:

email[[1]]$list_attachments()
iago nunes
  • 56
  • 9