npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

outlook

v1.1.4

Published

A package for calling the Outlook APIs from Node.

Downloads

137

Readme

Node.js Wrapper for Office 365 APIs Client Library

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

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

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 enpoint: 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.office365.com/api/v1.0',  
  authHelper.getAccessTokenFn('https://outlook.office365.com/', session)); 

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