Is there a way to read emails from a custom folder in MS-Exchange using EWS managed api (NodeJs implementation)? I'm able to read from the Inbox, but I have custom folder names where the emails are moved to that I'd like to have the code read in those folders.
what I have tried.
const EWS = require('node-ews');
const ewsConfig = {
username: '<Email>',
password: '<Password>',
host: '<Exchange URL>'
};
const ews = new EWS(ewsConfig);
const ewsFunction = 'FindItem';
var ewsArgs = {
'attributes': {
'Traversal': 'Shallow'
},
'ItemShape': {
't:BaseShape': 'IdOnly',
't:AdditionalProperties': {
't:FieldURI': {
'attributes': {
'FieldURI': 'item:Subject'
}
}
}
},
'ParentFolderIds': {
'DistinguishedFolderId': {
'attributes': {
'Id': '<Some Custom Folder>'
}
}
}
};
(async function () {
try {
let result = await ews.run(ewsFunction, ewsArgs);
console.log(result);
} catch (err) {
console.log(err.message);
}
})();
ERROR:
a:ErrorInvalidRequest: The request is invalid.: {"ResponseCode":"ErrorInvalidRequest","Message":"The request is invalid."}