亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 EWS 托管 api Nodejs 實現從自定義文件夾中讀取 MS-Exchange 電子郵件

使用 EWS 托管 api Nodejs 實現從自定義文件夾中讀取 MS-Exchange 電子郵件

莫回無 2023-05-11 13:54:31
有沒有辦法使用 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."}
查看完整描述

2 回答

?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

DistinguishedFolderId 不適用于非默認文件夾,因此我建議您嘗試


    'ParentFolderIds': {

        'FolderId': {

            'attributes': {

                'Id': '<Some Custom Folder>'

            }

        }

    }


查看完整回答
反對 回復 2023-05-11
?
瀟湘沐

TA貢獻1816條經驗 獲得超6個贊

我讓它工作的方法是首先找到FolderId使用FindFolder調用的方法:


const ewsArgs = {

  FolderShape: {

    BaseShape: 'AllProperties',

  },

  ParentFolderIds: {

    DistinguishedFolderId: {

      attributes: {

        Id: 'inbox',

      },

      Mailbox: {

        EmailAddress: '[email protected]',

      },

    },

  },

};


const { ResponseMessages } = await ews.run('FindFolder', ewsArgs, ews.ewsSoapHeader);


const found = ResponseMessages.FindFolderResponseMessage.RootFolder.Folders.Folder

  .find(f => f.DisplayName.match(new RegExp(folderName.toLowerCase(), 'ig')));

之后,您可以使用它來查找文件夾中包含以下呼叫的所有電子郵件FindItem:


const ewsArgs = {

  attributes: {

    Traversal: 'Shallow',

  },

  ItemShape: {

    BaseShape: 'IdOnly',

    // BaseShape: 'AllProperties',

  },

  ParentFolderIds: {

    FolderId: found.FolderId,

  },

};


const { ResponseMessages } = await ews.run('FindItem', ewsArgs, ews.ewsSoapHeader);


查看完整回答
反對 回復 2023-05-11
  • 2 回答
  • 0 關注
  • 205 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號