How can I access O365 from asp.net web form - outlook

I am working on an asp.net web form that has users with different O365 serviceses.
I mean they are not on the same AD, but come from different businesses.
I'm think they need to enter a username and password for their own system and then read the information.
Is there a way to access this calender information in C#?
I know there is Microsoft Graph, but can it be used with only a username and password without creating an applikation in Azure.

MS Graph is the most stable and efficient way of accessing O365 information nowadays. However, you may still use EWS or Outlook REST APIs, see Explore the EWS Managed API, EWS, and web services in Exchange for more information.
Here is what MS states in MSDN:
Microsoft recommends using Microsoft Graph to access Outlook mail, calendar, and contacts. You should use the Outlook APIs directly (via https://outlook.office.com/api) only if you require a feature that is not available on the Graph endpoints.
See Overview of using the Outlook REST APIs for information.

Related

Outlook addin - js or api generate email file

I have an outlook addin that I've built using Yeoman. The addin communicates with a server API on my server to combine data from an email with additional data from a database that a user has saved against an email address. This is all working great.
Next I want to store a copy of the email server side, as a file on disk, .msg preferred but I'll take a .eml if thats the only option.
I have 2 options but don't know if either are possible. Either the addin generates the .msg file and posts it to the server API OR the server side API generates the .msg file directly. I have got the server side using the Outlook v2 API and able to pull back the email information when the client passes it the token, id etc. If it could just generate/download a .msg file server side this would be ideal.
As a side note, many of the Microsoft API pages point out the deprecation of the Outlook API in favor of the Graph API, however there are inconsistent links between the pages and it get confusing. I have discovered the token from getCallbackTokenAsync only works with the Outlook API and not Graph, but I cant find out a way to generate a graph compatible token. All the example code from MS uses Office.context.mailbox.restUrl which still gives the Outlook API url and not Graph!
So I guess I'm trying to find out if it's even possible to get/generate a .msg or .eml file either client side using outlook.js or server side using one of the api's. Thank you.
I can get message data both client and server side but cannot get a physical email file.
The Office JavaScript API (OfficeJS) doesn't provide anything for saving messages as msg files (or getting streams). The best what you could do is to use Graph API where you could get the EML file, see Get MIME content of a message for more information.
The server-side code may use the OAuth 2.0 On-Behalf-Of flow (OBO) to request a new access token with permissions to Microsoft Graph. Read more about that in the Authorize to Microsoft Graph with SSO article.
The on-behalf-of (OBO) flow describes the scenario of a web API using an identity other than its own to call another web API. Referred to as delegation in OAuth, the intent is to pass a user's identity and permissions through the request chain.
For the middle-tier service to make authenticated requests to the downstream service, it needs to secure an access token from the Microsoft identity platform. It only uses delegated scopes and not application roles. Roles remain attached to the principal (the user) and never to the application operating on the user's behalf. This occurs to prevent the user gaining permission to resources they shouldn't have access to. See Microsoft identity platform and OAuth 2.0 On-Behalf-Of flow for more information.
Eugene's answer is good. If ultimately you need to get that message to your backend service, using Graph as Eugune described would be the recommended approach. If for whatever reason you are still looking for a capability to access it on client using Office.js, it is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process. Note there is already a couple of similar ideas there, if you search for "eml" keyword, that you may want to upvote.

Does the msgraph-sdk-javascript library support SSO-OBO?

I am currently looking for a good JS library to use for my addin. And I came across this project : MSGRAPH-SDK-JAVASCRIPT
I tried to read through their project details but could not find out definitively if they support the SSO-OBO flow for addins.
Has anybody used the said library successfully for an SSO-OBO flow?
Thank you very much.
Single sign on and MS Graph SDK are different things. You can use SSO to deal with Graph API from Outlook web add-ins. See Using Single Sign-On (SSO) with Office Add-ins for more information.
Also you may find the following posts helpful:
Authorize to Microsoft Graph with SSO
Authenticate a user with a single-sign-on token in an Outlook add-in

Outlook REST API - Application Permissions or Background Services

I'm currently using Microsoft Graph, but have been running into its limitation on the request size. Seeing as how the Outlook REST API doesn't have that limitation and is supposed to be very similar to the Graph API for mail related functions, I wanted to use the Outlook API for sending messages with larger attachments.
But is there a way to get application level permissions with the Outlook REST API? Or make calls without a user? The authentication approach I'm using with Microsoft Graph is the one outlined at https://learn.microsoft.com/en-us/graph/auth-v2-service and it would be nice to be able to do the same with the Outlook API.
My app is registered at the Microsoft Application Registration Portal, but the permissions there are only for Microsoft Graph. I have seen an article that mentions being able to edit the manifest in order to get permissions working with other APIs (like the Outlook API), but wasn't too sure about that.

Chatbot with Microsoft Office365/outlook Calendar

I want to develop a chatbot and want to integrate Microsoft Office365/Outlook calendar.
So flow of application will be like this:
1) From Admin panel Manager user will invite Partner users and partner users will come and connect to their office 365 calendar and and enable access to share it. Now this calendar will be available for chatbot.
2) on FrontEnd(chatbot) guest or registered users will provide their emails and book meeting from the available timing based on calendar.
.. guest users will provide there emails and get the available timing from a partner user calendar.
I started looking at Microsoft Graph API.
Can someone provide me with a good start?
To do this you will have to use the authentication features in bot framework. There is a good walkthrough to get you started. There is also a sample that demonstrates the use of the MS Graph API.

Accessing Appointments in Outlook without ActiveX

I'm currently working on a project where I'm sending and updating Appointsments. I would like to do this without the use of ActiveX since I don't want to be limited to IE. I've been googeling for quite some time now, but I couldn't find anything that helped, so here's my question. Is there any way I can access or update appointments without the use of ActiveX.
We also have access to the OutlookWebApp, so maybe there's an interface there. Would be great if someone had an idea. Thanks in advance and
Greetings Chris
You can use Exchange Web Services (web or desktop app) or the EWS Managed API (desktop app only) to access data in Exchange Mailboxes: https://msdn.microsoft.com/en-us/library/office/jj162981.aspx.
If you are working with Office 365 mailboxes you can use the Outlook REST or Microsoft Graph APIs: https://dev.outlook.com/
If your solution requires a UI in Outlook Online (OWA) then you can access contextual data (i.e. the current email or appointment) with an Outlook Add-in (you can use EWS requests from it as well): https://dev.outlook.com/reference/add-ins/

Resources