Azure / Microsoft365R

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

Does emayili work with business Outlook? #95

Closed smach closed 2 years ago

smach commented 2 years ago

I am trying to use emayili with my business Outlook. I tried to run this code from what I saw in your unit tests:

    ey_em <- emayili::envelope(
        to=to_addr,
        subject="test emayili email",
        html="test emayili email"
    )
    em <- folder$create_email(ey_em)

but my folderis authenticated with get_business_outlook() and my "test emayili email" is a "test.html" file, and I get this error:

Error: $ operator is invalid for atomic vectors

hongooi73 commented 2 years ago

As long as emayili can handle your input, everything should work fine. Check that you're supplying envelope with what it expects.

smach commented 2 years ago

Thank you. I checked with the creator of emayili who posted "unfortunately, the support in {Microsoft365R} is based on a very old version of {emayili}. A bit of work would be required to get it compatible again. I feel that the API of {emayili} has now stabilised, so it would be a reasonable thing to do at this stage." I'm not sure if you want to do that, but if not, you may want to change the Microsoft365R documentation that says it's compatible now.

hongooi73 commented 2 years ago

"Very old version", lol. It was one minor revision ago from earlier this year. Anyway, I've pushed a compatibility fix in the emayili-update branch. Can you try installing that and tell me if it works?

hongooi73 commented 2 years ago

@datawookie can you let me know if there are any issues with the fix? I'm not a heavy user of emayili.

datawookie commented 2 years ago

"Very old version"

A lot has changed in the package since then, so, yes it was a much older version.

datawookie commented 2 years ago

Hi @hongooi73,

Thanks for being so responsive in sorting out this issue.

I had to fiddle around a bit to get the tests to run. For future reference I'm going to record here what I needed to do.

  1. Create an .Renviron file with the following contents.
AZ_TEST_NATIVE_APP_ID="d44a05d5-c6a5-4bbb-82d2-443123722380"
AZ_TEST_OUTLOOK_FROM_ADDR="anne@example.com"
AZ_TEST_OUTLOOK_TO_ADDR="bob@example.com"
AZ_TEST_OUTLOOK_CC_ADDR="jane@example.com"
AZ_TEST_OUTLOOK_BCC_ADDR="rex@example.com"
  1. Restart R so that environment updated.
  2. Run devtools::test() from the console rather than running tests via the GUI.

And this is the result that I got for the relevant tests:

image

WDYT? I'm not quite sure why those few tests are failing and don't have the bandwidth now to dig in to figure it out. I'm assuming that you might have some ideas given your familiarity with the code. Very happy to bounce back and forth until we get this sorted.

Thanks, Andrew.

hongooi73 commented 2 years ago

Don't worry about test05_outlook and test05d_outlook_send, these are for testing code that's unrelated to emayili. The only tests that should be affected are test05b_outlook_email and test05c_outlook_attachment, and they are passing.

I just need someone who can give the code a more thorough workout, since I don't usually send email from R myself. I've tested the basic use cases but there may be some corner cases that break.

datawookie commented 2 years ago

Aha! Okay, cool, let me see if I can put together a some more detailed tests. :+1:

datawookie commented 2 years ago

@hongooi73 I've done some independent testing and this looks good to me.

datawookie commented 2 years ago

Hi @smach, can you please try installing from the emayili-update branch and then testing again?

Also, please check out the test-compatibility-microsoft365r.R file in the {emayili} repository for a slightly different approach to using {emayili} with {Microsoft365R}. Let me know how it goes.

Thanks, Andrew.

smach commented 2 years ago

@hongooi73 The test code works now, thanks!!! This is great.

@datawookie I used part of the test-compatibility-microsoft365r.R file and it seems to work fine too! The only thing I noticed is that I wasn't able to add more than 1 email address in the envelope() to argument, either as one string or a vector, when I ran outlook$create_email(msg). I can certainly live without that, just thought it was possible.

hongooi73 commented 2 years ago

Actually I just noticed that emayili handles addresses using a custom vctrs class. @datawookie can you have a look at my comment in the linked PR?

datawookie commented 2 years ago

@hongooi73 just had a look and it's :fire:.

jonspring commented 1 year ago

I was able to successfully run the example above, but ran into problems when I tried to take rendered HTML from {emayili} and pass it into {Microsoft365R}. The link below demonstrates a minimal example of the issue.

https://github.com/datawookie/emayili/issues/99#issuecomment-1445282353