【问题标题】:Read MS-Exchange emails from a custom folder using EWS managed api Nodejs implementation使用 EWS 托管 api Nodejs 实现从自定义文件夹中读取 MS-Exchange 电子邮件
【发布时间】:2020-10-14 03:53:34
【问题描述】:

有没有办法使用 EWS 托管 api(NodeJs 实现)从 MS-Exchange 中的自定义文件夹中读取电子邮件?我可以从收件箱中读取信息,但我有自定义文件夹名称,电子邮件被移到了我希望在这些文件夹中读取代码的位置。

我尝试过的。

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);
    }
})();
    

错误:

a:ErrorInvalidRequest: The request is invalid.: {"ResponseCode":"ErrorInvalidRequest","Message":"The request is invalid."}

【问题讨论】:

    标签: javascript node.js exchangewebservices node-ews


    【解决方案1】:

    DistinguishedFolderId 不适用于非默认文件夹,因此我建议您尝试

        'ParentFolderIds': {
            'FolderId': {
                'attributes': {
                    'Id': '<Some Custom Folder>'
                }
            }
        }

    【讨论】:

    • 谢谢,它没有将文件夹名称作为 ID。它应该是文件夹实际 ID(长字符串)
    猜你喜欢
    • 2015-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    • 2015-11-30
    相关资源
    最近更新 更多