-
-
Save maccyber/a57e3b7f8ded3d72205c817cf4c5b377 to your computer and use it in GitHub Desktop.
This file contains 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 characters
var ews = require('ews-javascript-api') | |
var ntlmXHR = require('./ntlmXHRApi') | |
var config = require('../config') | |
var ntlmXHRApi = new ntlmXHR.NtlmXHRApi(config.username, config.password) | |
// create ExchangeService object | |
function getTasks (callback) { | |
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013) | |
exch.XHRApi = ntlmXHRApi | |
exch.Credentials = new ews.ExchangeCredentials(config.username, config.password) | |
// ews.EwsLogging.DebugLogEnabled = false // turn off logging | |
exch.ImpersonatedUserId = new ews.ImpersonatedUserId(ews.ConnectingIdType.SmtpAddress, 'usersmail@mail.com') | |
// set ews endpoint url to use | |
exch.Url = new ews.Uri(config.url) // you can also use exch.AutodiscoverUrl | |
var folder = new ews.FolderId(ews.WellKnownFolderName.Tasks) | |
var sf = new ews.SearchFilter.IsNotEqualTo(ews.TaskSchema.IsComplete, true) | |
var view = new ews.ItemView(config.tasks) | |
var items = [] | |
var i = 0 | |
exch.FindItems(folder, sf, view) | |
.then((response) => { | |
items = response.Items | |
var obj = [] | |
for (i in items) { | |
var item = { | |
systemid: 'exchange', | |
timestamp: new Date().getTime(), | |
title: items[i].Subject, | |
url: config.tasksUrl | |
} | |
obj.push(item) | |
} | |
return callback(null, obj) | |
}, (err) => { | |
return callback(err) | |
} | |
) | |
} | |
module.exports = getTasks | |
getTasks(function (err, data) { | |
console.log(err || data) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment