请任何人都可以帮助ews-javascript-api中的GetUserAvailability方法。我目前正在使用这个exchange api开发一个房间预订系统,但是我遇到了一个问题,我找不到解决方案。请需要你的帮助伙计们
const room = 'roomemail@email.com'
const user = 'email@email.com'
var myPwd = 'password'
// Dependencies
var ews = require("ews-javascript-api");
// Debug Mode
ews.EwsLogging.DebugLogEnabled = false;
// Login to Exchange URI, Username and Password, Version of Exchange
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.ExchangeCredentials(user, myPwd);
exch.Url = new ews.Uri("https://mail.domain.com");
// Check Availability
var now = new Date();
now.setMinutes(now.getMinutes() + 1);
var startTime = new ews.DateTime(now);
var tw = new ews.TimeWindow(ews.DateTime.Now, ews.DateTime.Now.AddHours(8));
var attendee = new ews.AttendeeInfo("roomemail@email.com");
var result = new exch.GetUserAvailability(attendee, tw, ews.AvailabilityData.FreeBusyAndSuggestions);
console.log(result);
然后我得到了这个错误:
../ews javascript api/js/Core/EwsUtility.js:567抛出新的ArgumentException_1.ArgumentException(Strings_1.Strings.CollectionIsEmpty,paramName);^异常:集合为空。at Function.EwsUtilities.ValidateParamCollection(/Users/rsatraj/node_moduless/ews-javascript api/js/Core/EwsUtility.js:567:19)at new ExchangeService.GetUserAvailability(/Users/rsatraj/node_modules/ews javascript api/js/Core/ExchangeService.js:1402:37)at Object。(/Users/rsatraj/booking.js:46:14)在模块_在Function.module.runMain(module.js:69:3:10)的Function.Modules_load(module.js:693:10)处(bootstrap_node.js:191:16),在启动时(bootstrap.node.js:191:16)
截至目前,我不确定该怎么办。你们能帮我这个吗?任何信息都会有所帮助!真的很感激
GetUser可用性
不是类,它是Exchange eService
类中的一个方法。它还需要与会者数组,而不仅仅是一个,这会返回一个promise,而不是像c#版本那样的同步代码。您可以使用. then
带或不带.catch
您也可以在最新的节点中将其与asyncawait一起使用。
当在异步函数var结果=等待exch. GetUser可用性([与会者],tw,ews.可用性Data.FreeBusyAndSuggestions);
当使用Promiseexch. GetUser可用性([参会人员],tw,ews.可用性Data.FreeBusyAndSuggestions).then(函数(结果){/*用结果做某事*/},函数(错误){/*发生错误时做某事*/})