有没有测试Exchange连接的方法?

时间:2019-07-02 13:31:57

标签: javascript node.js asynchronous exchangewebservices

我必须从nodejs应用程序发送一些邮件,并且我想从类的构造函数中抛出一个异常,如果凭据错误,我将使用该异常来处理邮件,但是我找不到方法做这个; 我正在使用模块ews-javascript-api连接到Exchange Server。

我曾尝试将测试邮件发送到假地址,但是由于sender方法返回了一个Promise,因此我无法抛出异常,因此无法正常工作。

class ExchSender{
    constructor(username, passowrd){
        this.exch = new ExchangeService();
        this.exch.Credentials = new ews.ExchangeCredentials(username, password);
        this.exch.Url = new Uri('https://exchange.exch/ews/exchange.asmx');

        //Here I'd like to test the connection and throw the exception
    }
}

1 个答案:

答案 0 :(得分:0)

如果您只想检查凭据,请在services.wsdl上进行正常的获取,这将需要身份验证。这并不能真正检查Exchange连接,仅检查IIS是否可用以及凭据在端点上是否有效。是否可以绑定到“收件箱”文件夹将是一个正确的连接测试,因为这将告诉您邮箱是可用的,因为在IIS端点可用的后端上有很多东西,例如商店可能处于脱机状态,正在移动或服务处于停止等