Last active
May 20, 2018 00:44
-
-
Save gautamsi/1c267504b5d4c759afc2a93def67e4d1 to your computer and use it in GitHub Desktop.
Revisions
-
gautamsi revised this gist
Apr 6, 2017 . 2 changed files with 68 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,28 @@ "use strict"; var ews = require("ews-javascript-api"); var credentials = require("../credentials"); ews.EwsLogging.DebugLogEnabled = false; var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013); exch.Credentials = new ews.ExchangeCredentials(credentials.userName, credentials.password); exch.Url = new ews.Uri("https://outlook.office365.com/Ews/Exchange.asmx"); exch.SubscribeToStreamingNotifications([new ews.FolderId(ews.WellKnownFolderName.Inbox)], ews.EventType.NewMail, ews.EventType.Created, ews.EventType.Deleted, ews.EventType.Modified, ews.EventType.Moved, ews.EventType.Copied, ews.EventType.FreeBusyChanged) .then(function (streamingSubscription) { var connection = new ews.StreamingSubscriptionConnection(exch, 1); console.log("subscribing....: "); connection.AddSubscription(streamingSubscription); connection.OnNotificationEvent.push(function (obj, notificationArgs) { console.log("notification received: "); ews.EwsLogging.Log(obj, true, true); // EwsLogging.Log(notificationArgs, true, true); }); connection.OnDisconnect.push(function (connection, subscriptionErrorEventArgsInstance) { console.log("disconnecting..."); ews.EwsLogging.Log(subscriptionErrorEventArgsInstance, true, true); //access subscriptionErrorEventArgsInstance //connection.Open(); }); connection.Open(); }, function (err) { console.log("ERROR: --------------- "); console.log(err); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ import { EwsLogging, ExchangeService, ExchangeVersion, ExchangeCredentials, Uri, FolderId, EventType, WellKnownFolderName, StreamingSubscriptionConnection, } from "ews-javascript-api"; import credentials = require("../credentials"); EwsLogging.DebugLogEnabled = false; var exch = new ExchangeService(ExchangeVersion.Exchange2013); exch.Credentials = new ExchangeCredentials(credentials.userName, credentials.password); exch.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx"); exch.SubscribeToStreamingNotifications( [new FolderId(WellKnownFolderName.Inbox)], EventType.NewMail, EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved, EventType.Copied, EventType.FreeBusyChanged) .then((streamingSubscription) => { let connection = new StreamingSubscriptionConnection(exch, 1); console.log("subscribing....: "); connection.AddSubscription(streamingSubscription); connection.OnNotificationEvent.push((obj, notificationArgs) => { console.log("notification received: ") EwsLogging.Log(obj, true, true); // EwsLogging.Log(notificationArgs, true, true); }); connection.OnDisconnect.push((connection, subscriptionErrorEventArgsInstance) => { console.log("disconnecting..."); EwsLogging.Log(subscriptionErrorEventArgsInstance, true, true); //access subscriptionErrorEventArgsInstance //connection.Open(); }); connection.Open(); }, (err) => { console.log("ERROR: --------------- "); console.log(err); }); -
gautamsi created this gist
Apr 6, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ "use strict"; var ews = require("ews-javascript-api"); var credentials = require("../credentials"); //import {MockXHRApi} from "./MockXHRApi"; ews.EwsLogging.DebugLogEnabled = false; var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013); exch.Credentials = new ews.ExchangeCredentials(credentials.userName, credentials.password); exch.Url = new ews.Uri("https://outlook.office365.com/Ews/Exchange.asmx"); exch.SubscribeToStreamingNotifications([new ews.FolderId(ews.WellKnownFolderName.Inbox)], ews.EventType.NewMail, ews.EventType.Created, ews.EventType.Deleted, ews.EventType.Modified, ews.EventType.Moved, ews.EventType.Copied, ews.EventType.FreeBusyChanged) .then(function (streamingSubscription) { var connection = new ews.StreamingSubscriptionConnection(exch, 1); console.log("subscribing....: "); connection.AddSubscription(streamingSubscription); connection.OnNotificationEvent.push(function (obj, notificationArgs) { console.log("notification received: "); ews.EwsLogging.Log(obj, true, true); // EwsLogging.Log(notificationArgs, true, true); }); connection.OnDisconnect.push(function (connection, subscriptionErrorEventArgsInstance) { console.log("disconnecting..."); ews.EwsLogging.Log(subscriptionErrorEventArgsInstance, true, true); //access subscriptionErrorEventArgsInstance //connection.Open(); }); connection.Open(); }, function (err) { debugger; console.log("ERROR: --------------- "); console.log(err); });