Asmi
Asmi

Reputation: 187

How to get .eml or base 64 of an email message in outlook 365 web addin?

I want to create an outlook web add-in ,in which I want .eml and and .txt of the email message and its attachment list? I am confused between EWS , Outlook RestAPI and MS Graph API to build it. I tried using EWS , but it had two issues:

  1. where to get these credentials ,(an example would be helpful)

    service = new ExchangeService { Credentials = new WebCredentials(OutlookEmailId, Password)

                     };
    
  2. EWS are obsolete now.

So what is the right way of getting the email message content ? Could anyone please explain the steps in plain english. Also, any example would be a big help to start.

I am newbie in these integration and OAUTH concepts, please suggest. I want to put my efforts in right direction.

Upvotes: 1

Views: 1908

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

  1. EWS isn't obsolete (and won't be for some time) it just basic Auth has been deprecated which should be an issue in Modern Addin.

You can get the Mime content of a Message (which is basically what is the content of an EML file) using the Graph eg https://learn.microsoft.com/en-us/graph/outlook-get-mime-message. To use that in a Addin you need to use make use of SSO see https://github.com/OfficeDev/Outlook-Add-in-SSO which has a pretty comprehensive sample you just need to change some of the REST call to do what you want.

There is working sample of using EWS in a Addin on https://gsexdev.blogspot.com/2019/05/outlook-addin-for-exporting-email-to.html (this has the 1MB limitation)

If you trying to go past 1MB there a few options to take with EWS use the answer in How can I retrieve the full MIME message from an Microsoft Outlook Add-In?.

Upvotes: 1

Related Questions