A very handy guide to custom connectors is available on the Outlook Dev Center: Office 365 Connectors for Groups (Developer Preview)
In this post, lets have a very simple look at how to use a custom connector from your ASP.NET MVC application.
The sample code for this post is available here: https://github.com/vman/Office365GroupsConnector
Before we get started, it is recommended to have SSL configured for your ASP.NET MVC application:
Configuring an ASP.NET project for development with SSL
1) The Connect to Office 365 button:
And the description for each query string parameter from the Outlook Dev Center page:
|You can use the |
|Provide your application name. This name will show up in the authorization popup and in the connector list page that your users would see. The |
|Provide the URL to your application logo. Ensure that the link is not behind an authentication wall and is publicly reachable. Use a logo of size under 10KB (preferably 256x256px) and type JPEG, PNG, GIF, TIFF, BPM, X-ICON or SVG+XML. The |
|The callback URL should be a valid HTTPS URL without any query parameters. When the application returns successfully, the state passed, name and webhook URL of the selected group are returned as query parameters to the |
This is how the button is rendered on your custom page:
When you click on the button, you are taken to the Office 365 Sign-in page if you are not already signed in. Next, you get a list of Office 365 Groups which you are a member of. You have to select a group in which the message will be posted, and click on Allow:
3) The Code:
The next step is to actually post the Office 365 Group card. Behind the scenes, I have used RestSharp in an MVC controller to make the post:
4) Navigate to the Office 365 Group:
And if you now navigate to the Office 365 Group in Outlook, you will see 2 new messages, the first one is when the connection to the custom application is set:
And the next one is the actual message we posted from the MVC controller:
Thanks for reading!
- For me, the code only worked on Chrome and not on IE. Even then, I would get timeouts during the authentication part.
- I would also get the following error intermittently if I was not already signed in to Outlook. The workaround was to open a another tab and sign in to Outlook which then made the authentication work.