Reputation: 187
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:
where to get these credentials ,(an example would be helpful)
service = new ExchangeService { Credentials = new WebCredentials(OutlookEmailId, Password)
};
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
Reputation: 22032
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