OfficeDev/Outlook-Add-in-Sharing-to-OneDrive

Name: Outlook-Add-in-Sharing-to-OneDrive

Owner: Office Developer

Description: An Outlook Add-in that provides users the ability to share OneDrive links to email recipients.

Created: 2016-03-24 16:32:55.0

Updated: 2017-12-06 20:18:36.0

Pushed: 2018-01-16 09:56:41.0

Homepage:

Size: 135

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Microsoft Outlook Add-in Sharing to OneDrive

Users can now share a OneDrive item directly from within an Outlook add-in. In this sample, we show you how to use the JavaScript API for Office, and the OneDrive API to create a Microsoft Outlook Add-in that displays which email recipients have permission to view the OneDrive link in the message body. If there are recipients that don't have the proper permission to view the link(s), the user will have the option to grant permissions to selected recipients.

With the OneDrive shares API, you can programmatically get permissions for an item by using the item's link. You can then use the same shares API, with action.invite, to share the URL with email recipients.

Table of Contents
Prerequisites

This sample requires the following:

Note: This sample currently only works with consumer OneDrive service.

Configure the project
  1. Get a token from the OneDrive developer site. To get a token, go to OneDrive authentication and sign in and click Get Token. Copy the token, which is after the text Authentication: bearer and save it to a text file. This token is valid for one hour, and gives you read/write access to the signed in user's OneDrive files. You'll be required to sign in to your personal OneDrive.

  2. Open the solution file OutlookAddinOneDriveSharing.sln and in the \app\authentication.config.js file, paste the token, like this:

    N = '<your_token>';
    
  3. In Solution Explorer, click the OutlookAddinOneDriveSharing project and in the Properties window, change Start Action to Office Desktop Client.

  4. Right-click the OutlookAddinOneDriveSharing project and choose Set as StartUp Project.

  5. Close Outlook desktop client.

Run the project

Press F5 to run the project. You'll be prompted to enter an email and password to use for running Outlook. Enter your Exchange email and password. Note This may be different from your personal OneDrive account email and password.

Once the Outlook desktop client has started, click New Email to compose a new message.

Important If you weren't prompted to accept the installation for the IIS Express Development Certificate, navigate to Control Panel | Add/Remove Programs and choose IIS Express. Right-click and choose Repair. Restart Visual Studio and open the OutlookAddinOneDriveSharing.sln file.

This add-in uses add-in commands, so you launch the add-in by choosing this command button on the ribbon:

Check access command button on the ribbon

A task pane appears with the list of recipients. The list is divided by who has permission to view the link, and who doesn't. Note Any time you add or remove recipients, or change the link, click the command button again to refresh the list.

To get a OneDrive link, sign in to your OneDrive account at www.onedrive.com and choose one of your files. Copy the link for that file and paste it into the body of the email message.

Understand the code
Remarks
Questions and comments

We'd love to get your feedback about the Outlook Add-in Sharing to OneDrive sample. You can send your feedback to us in the Issues section of this repository. Questions about Office 365 development in general should be posted to Stack Overflow. Make sure that your questions are tagged with [Office365] and [API].

Additional resources
Copyright

Copyright (c) 2016 Microsoft. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.