GithubHelp home page GithubHelp logo

isabella232 / outlook-add-in-javascript-viewyoutubevideos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from officedev/outlook-add-in-javascript-viewyoutubevideos

0.0 0.0 0.0 870 KB

This Outlook Add-in allows users to view YouTube videos in the add-in pane in Outlook. It also contains a setup script that deploys the app to a Ruby web server.

License: Other

Shell 20.42% CSS 6.93% JavaScript 1.05% HTML 62.53% Ruby 9.07%

outlook-add-in-javascript-viewyoutubevideos's Introduction

page_type products languages extensions
sample
office-outlook
office-365
html
javascript
ruby
contentType technologies createdDate
samples
Add-ins
8/11/2015 3:48:02 PM

Outlook add-in: View YouTube Videos

Summary

This Outlook Add-in allows users to view YouTube videos in the add-in pane in Outlook if the selected email message or appointment contains a URL to a video on YouTube. It also contains a setup script that deploys the add-in to a Ruby web server running on a Mac. The following figure is a screen shot of the YouTube add-in activated for a message in the Reading Pane.

Outlook Addin running a YouTube video in the mail item

Prerequisites

Key components of the sample

Description of the code

The main code files for this add-in are manifest.xml and youtube.html, along with the JavaScript library and string files for Office add-ins, and a logo image file. The following is a high-level summary of how the add-in works:

This mail add-in specifies in the manifest.xml file that it requires a host application that supports the mailbox capability:

<Capabilities>
    <Capability Name="Mailbox"/>
</Capabilities>
<DesktopSettings>
    <!-- Change the following line to specify the web server where the HTML file is hosted. -->
    <SourceLocation DefaultValue="https://webserver/YouTube/YouTube.htm"/>
    <RequestedHeight>216</RequestedHeight>
</DesktopSettings>
<TabletSettings>
    <!-- Change the following line to specify the web server where the HTML file is hosted. -->
    <SourceLocation DefaultValue="https://webserver/YouTube/YouTube.htm"/>
    <RequestedHeight>216</RequestedHeight>
</TabletSettings>

The add-in also requests the ReadItem permission in the manifest file so that it can run regular expressions, which is explained below.

    <Permissions>ReadItem</Permissions>

The host application activates this add-in when the selected message or appointment contains a URL to a YouTube video. It does so by first reading on startup the manifest.xml file, which specifies an activation rule that includes a regular expression to look for such a URL:

<Rule xsi:type="ItemHasRegularExpressionMatch" PropertyName="BodyAsPlaintext" RegExName="VideoURL" RegExValue="http://(((www\.)?youtube\.com/watch\?v=)|(youtu\.be/))[a-zA-Z0-9_-]{11}"/>

The add-in defines an initialize function that is an event handler for the initialize event. When the run-time environment is loaded, the initialize event is fired, and then the initialize function calls the main function of the add-in, init, as shown in the code below:

Office.initialize = function () {
    init(Office.context.mailbox.item.getRegExMatches().VideoURL);
}

The getRegExMatches method of the selected item returns an array of strings that match the regular expression VideoURL, which is specified in the manifest.xml file. In this case, that array contains URLs to videos on YouTube.

The init function takes as an input parameter that array of YouTube URLs and dynamically builds the HTML to display the corresponding thumbnail and details for each video.

This dynamically built HTML displays the first video in a YouTube embedded player, together with details about the video. The add-in pane also displays the thumbnails of any subsequent videos. The end user can choose a thumbnail to view any of the videos in the YouTube embedded player, without leaving the host application.

Set up

Shipped with this sample is a setup.sh - this setup file does the following:

To run the script, type at your POSIX-compliant terminal:

$ bash setup.sh

Start the server

From the project root, run:

$ rackup

Trust your self-signed certificate

Because this sample uses a local server and self-signed certificate, you must first establish 'trust' between your localhost and the self-signed certificate. Before Outlook will transmit any potentially sensitive data to any add-in, its SSL Certificate is verified for trust. This requirement helps protect the privacy of your data. Any modern web browser will alert the user to certificate discrepancies, and many also provide a mechanism for inspecting and establishing trust. After starting your local server, open your web browser of choice and navigate to the locally hosted URL specified in your manifest.xml file. (By default, the setup.sh script in this sample specifies this URL as https://0.0.0.0:8443/youtube.html.) At this point you may be presented with a certificate warning. You need to trust this certificate.

Open Safari
Safari security diloag to validate the certificate
Select 'Always trust' your self-signed certificate
Safari security diloag to always trust the Contoso certificate

Install the add-in to Office 365

Installation of this sample add-in requires access to Outlook on the web. Installation can be performed from Settings > Manage apps.

Select 'Settings' and 'Manage apps' menu Install from file
Settings dropdown for manage apps add from a file settings property page
Select the manifest.xml file
add from a file properties page setting the manifest name
Select 'Install' and then 'Continue'
add from a file properties page setting confirmation to add

See it in action

To demonstrate the functionality of the add-in, you'll need to use the Office Outlook 2013 native client.

  • Open Outlook 2013
  • Email yourself a link to a YouTube video - Need a suggestion?
  • Expand the add-in pane to see a preview

Questions and comments

  • If you have any trouble running this sample, please log an issue.
  • Questions about Office Add-in development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [office-addins].

Additional resources

Copyright

Copyright (c) 2015 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-javascript-viewyoutubevideos's People

Contributors

davidchesnut avatar dependabot[bot] avatar elizabethsamuel-msft avatar iambmelt avatar lindalu-msft avatar mimisasouvanh avatar o365devx avatar paulstubbs 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.