Query Microsoft's Exchange Web Services. Only tested on Microsoft Exchange 2010. With asynchronous promises.
##Install
Install with npm:
npm install exchanger
##Module
###exchanger.initialize(settings)
var exchanger = require('exchanger');
exchanger.initialize({ url: 'webmail.example.com', username: 'username', password: 'password' })
.then(function(client) {
console.log('Initialized!');
});
###exchanger.getEmails(client, folderName, limit, emailAddress)
var exchanger = require('exchanger');
exchanger.initialize({ url: 'webmail.example.com', username: 'username', password: 'password' })
.then(function(client) {
return exchanger.getEmails(client, 'inbox', 50, 'email@test.com');
})
.then(function(emails){
console.log(emails);
});
###exchanger.getEmail(client, id)
var exchanger = require('exchanger');
exchanger.initialize({ url: 'webmail.example.com', username: 'username', password: 'password' })
.then(function(client) {
return [client, exchanger.getEmails(client, 'inbox', 50, 'email@test.com')];
})
.then(function(client, emails){
return exchanger.getEmail(client, emails[0].id);
})
.then(function(email){
console.log(email);
});
###exchanger.getFolders(client, folderName, emailAddress)
var exchanger = require('exchanger');
exchanger.initialize({ url: 'webmail.example.com', username: 'username', password: 'password' })
.then(function(client) {
return exchanger.getFolders(client, 'inbox', 'email@test.com');
})
.then(function(folders){
console.log(folders);
});
##Support for callbacks rather then promises
var exchanger = require('exchanger').withCallbacks;
exchanger.initialize({ url: 'webmail.example.com', username: 'username', password: 'password' }, function(err) {
console.log(err);
exchanger.getEmails('inbox', 50, 'email@test.com', function(err, emails){
if(err){
console.log(err);
return;
}
console.log(emails);
});
});
###Other Information EWS reference for Exchange