GithubHelp home page GithubHelp logo

isabella232 / outlook-add-in-sharing-to-onedrive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from officedev/outlook-add-in-sharing-to-onedrive

0.0 0.0 0.0 147 KB

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

License: MIT License

C# 3.70% CSS 11.73% JavaScript 74.20% HTML 10.36%

outlook-add-in-sharing-to-onedrive's Introduction

page_type products languages extensions
sample
office-outlook
office-onedrive
office-365
javascript
contentType technologies createdDate
samples
Add-ins
3/24/2016 9:32:55 AM

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:
TOKEN = '<your_token>';
  1. In Solution Explorer, click the OutlookAddinOneDriveSharing project and in the Properties window, change Start Action to Office Desktop Client.

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

  3. 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

  • app.js - In app.js, a global object of recipients is created by using the Office.context.mail.item.getAsync to get recipients from the message. Links are obtained in the same way, with Office.context.mail.item.body.getAsync.
  • onedrive.share.service.js - An object to handle requests to the OneDrive API. This object includes:
    • A link property to maintain links.
    • A request method to send requests to the OneDrive API endpoint, and to use the shares and permissions API.
    • A UI object to render the display to the task pane.
  • render.controller.js - An object to control the display in the task pane.

Remarks

  • The sample checks only the first link in the message body.
  • You must use a personal OneDrive account to get the token.
  • If you are using an Outlook account for your personal OneDrive account and it hasn't been migrated to Office 365, sharing may not work. To check if your email account was migrated, sign in to Outlook.com and if the upper left hand corner says Outlook.com, it's not migrated.

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 [email protected] with any additional questions or comments.

outlook-add-in-sharing-to-onedrive's People

Contributors

andrewjmay avatar davidchesnut avatar mimisasouvanh avatar o365devx avatar officegsx avatar paulstubbs avatar rick-kirkham avatar tadaomachida avatar v-pazal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.