Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
313 stars 44 forks source link

Warning message when sending to multiple recipients #134

Closed mlamias closed 1 year ago

mlamias commented 2 years ago

I am attempting to send a message to multiple email recipients using the following sample code:

outlook <- get_business_outlook()
  my_email <- outlook$create_email(content_type = "html")$
  set_body("<p>This is my email body <strong>with bold text</strong>.</p>")$
  set_subject("My 2nd email subject")$
  set_recipients(to = c("recipient1@mail.com", "recipient2@mail.com"))
  my_email$send()

The email appears to be sent correctly to all recipients, but when I sent up the email message, I receive a warning message that reads as follows:

Warning messages:
1: In !is_empty(addr_list) && is.na(addr_list) :
  'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In is_empty(x) || !is.na(x) :
  'length(x) = 2 > 1' in coercion to 'logical(1)'

When I address the email to only a single recipient, I do not get this warning. Is there a reason why I receive this message when attempting to send to multiple recipients? Is there a different method of constructing the code to avoid this warning message, or is this a bug of some sort?

Thanks.

btcooper22 commented 2 years ago

I'm getting this error also after updating R to 4.2 from 4.1. I suspect it's to do with this change: https://bitcoden.com/answers/r-warning-lengthx-2-1-in-coercion-to-logical1

msgoussi commented 1 year ago

work around by using semicoma, ie "recipient1@mail.com;recipient2@mail.com"

robayo commented 1 year ago

Hey @hongooi73 I saw your commit where you added the if(!is_empty(addr_list) && any(is.na(addr_list))) to solve this issue but i think you missed line 116 where the same pattern repeats. Now, in R 4.3 this behaviour is no longer a warning but an error. https://github.com/Azure/Microsoft365R/blob/0b44737257b6b0c46d60471b294822d9001f5d9f/R/build_email_request.R#L116 I created a fork that solves this problem #150

hongooi73 commented 1 year ago

@robayo thanks for the heads-up, I've added the fix.

msgoussi commented 1 year ago

Hi... I am still getting the error below even after devtools::install_github("Azure/Microsoft365R") to get the most updated version of the package.

Error in !is_empty(addr_list) && is.na(addr_list) : 'length = 3' in coercion to 'logical(1)'

hongooi73 commented 1 year ago

This should be fixed in the dev branch. Let me know if it still breaks.

msgoussi commented 1 year ago

i have reinstalled the package via devtools::install_github("Azure/Microsoft365R", force = TRUE), and i am still getting the same error .... Please advise.

hongooi73 commented 1 year ago

You have to install the dev branch: install_github("Azure/Microsoft365R@dev")