• This repository has been archived on 19/May/2020
  • Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple wrapper around the Microsoft Office 365 APIs Client Libraries for Cordova Applications.

Node.js Wrapper for Office 365 APIs Client Library

IMPORTANT

I a no longer maintaining this library, and I'm archiving this repository. Please consider using the Microsoft Graph JavaScript Client Library instead.

This library provides a light-weight implementation of the Outlook Mail, Calendar, and Contacts APIs.

For a sample app that uses this library, see Getting Started with the Outlook Mail API and Node.js.

The original version of this library was a simple wrapper intended to enable use of the Microsoft Office 365 APIs Client Libraries for Cordova Applications from a Node.js app. This version still includes the old interfaces, but no further development is being made on that part of this library. It is recommended that applications use the new interfaces moving forward.

Required software

Contributing

See CONTRIBUTING.md

Installation

Installing should be done via NPM:

npm install node-outlook

Usage

Once installed, add the following to your source file:

var outlook = require("node-outlook");

New interface

The new interface is documented in a simple reference (courtesy of jsdoc-to-markdown).

Configuration

Configuration of the library is done via the base namespace:

  • outlook.base.setApiEndpoint - Use this to override the API endpoint. The default value uses the Outlook v1.0 endpoint: https://outlook.office.com/api/v1.0.
  • outlook.base.setAnchorMailbox - Set this to the user's SMTP address to enable the API endpoint to efficiently route API requests.
  • outlook.base.setPreferredTimeZone - Use this to specify a time zone for the server to use to return date/time values in the Calendar API.

Making API calls

The library has a namespace for each API.

  • outlook.mail - The Mail API
  • outlook.calendar - The Calendar API
  • outlook.contacts - The Contacts API

Each namespace has minimal functions (more to come). Usage is similar between the namespaces. For example, this is how you call the getMessages function in the outlook.mail namespace:

// Specify an OData query parameters to include in the request
var queryParams = {
  '$select': 'Subject,ReceivedDateTime,From',
  '$orderby': 'ReceivedDateTime desc',
  '$top': 10
};

// Set the API endpoint to use the v2.0 endpoint
outlook.base.setApiEndpoint('https://outlook.office.com/api/v2.0');
// Set the anchor mailbox to the user's SMTP address
outlook.base.setAnchorMailbox(email);

outlook.mail.getMessages({token: token, odataParams: queryParams},
  function(error, result){
    if (error) {
      console.log('getMessages returned an error: ' + error);
    }
    else if (result) {
      console.log('getMessages returned ' + result.value.length + ' messages.');
      result.value.forEach(function(message) {
        console.log('  Subject: ' + message.Subject);
        var from = message.From ? message.From.EmailAddress.Name : "NONE";
        console.log('  From: ' + from);
        console.log('  Received: ' + message.ReceivedDateTime.toString());
      });
    }
  });

Making raw API calls

If the library does not implement a function that does what you need, you can use the outlook.base.makeApiCall method to call any API call implemented on the server. See the implementations of any methods in the outlook.mail, outlook.calendar, or outlook.contacts namespaces for an example of how to use this method.

Old interface

As a reminder, the old interface is no longer being developed. It's recommended that you use the new interface.

You can create an OutlookServices.Client object like so:

var outlookClient = new outlook.Microsoft.OutlookServices.Client('https://outlook.office.com/api/v2.0',
  authHelper.getAccessTokenFn('https://outlook.office.com/', session));

Where authHelper.getAccessTokenFn is a callback method you implement to provide the needed OAuth2 access token.

Copyright

Copyright (c) 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.


Connect with me on Twitter @JasonJohMSFT

Follow the Outlook Dev Blog

More Repositories

1

ruby_outlook

A gem wrapper around the Mail, Calendar, and Contacts APIs.
Ruby
68
star
2

python_tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-pythondjangoapp
Python
61
star
3

php-calendar

A PHP sample using the Calendar API for Office 365.
PHP
58
star
4

node-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-nodeexpressapp
JavaScript
53
star
5

php-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-phpapp
PHP
45
star
6

node-calendar-sync

This is a sample Node.js app that connects to Office 365 to do calendar sync.
JavaScript
41
star
7

pythoncontacts

A sample illustrating using the Office 365 APIs from Python/Django
Python
40
star
8

send-actionable-message

A command-line sample that uses Microsoft Authentication Library and the Microsoft Graph Client Library to send a message with an actionable message card to the authenticated user.
C#
38
star
9

javascript-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-javascriptspa
JavaScript
34
star
10

o365-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-rubyrailsapp
Ruby
33
star
11

office365-azure-guides

A place to add guides for OAuth2 authentication to Office 365 APIs.
C#
31
star
12

java-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-java
Java
30
star
13

python_clientcred

A basic sample of the client credential OAuth flow and Mail API using Python/Django.
Python
22
star
14

dotnet-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-aspnetmvcapp
JavaScript
15
star
15

o365-vcftool

A Ruby on Rails sample that uses the Contacts API in Microsoft Graph.
Ruby
12
star
16

java-calendar-demo

A sample Java web app that implements the client credential auth flow to call Microsoft Graph.
Java
10
star
17

simple-survey

This is a starter project and step-by-step guide for implementing a demo survey application using Outlook Actionable Messages and Office 365 Group Connectors.
JavaScript
10
star
18

swift-tutorial

For a current sample, see https://github.com/microsoftgraph/msgraph-training-ios-swiftA simple Swift tutorial to use the Mail API.
Swift
9
star
19

git-the-gist

This sample add-in uses the GitHub Gists API to access a user's gist and insert them into a new message.
HTML
8
star
20

node-service

A simple Node.js script that uses the client credential OAuth2 flow to access Outlook data without requiring user logon.
JavaScript
4
star
21

outlook-fetch

A command-line sample that uses the client credentials grant flow to authenticate and call the Outlook APIs.
C#
3
star
22

rest-sender

Simple command line tool to send REST requests to Graph or Outlook
C#
1
star
23

vs-outlook-addin

JavaScript
1
star
24

jasonjohRepo0822184943

PowerShell
1
star
25

outlook-api-demo

An MVC ASP.NET web app that calls the Outlook API endpoint
JavaScript
1
star
26

dotnet-outlook-nosdk

An ASP.NET web app that calls the Outlook APIs without using the Outlook library on NuGet.
C#
1
star