私はEWSのAPIを使用して電子メールを送信しようとすると、私は次のエラーを取得する:(message.Send();
に)のExchange WebサービスAPIと401不正例外
The request failed. The remote server returned an error: (401) Unauthorized.
私のコードは以下の通りです:
ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
//WebService Uri
try
{
exchangeService.Url = new Uri("https://exchangeserver/ews/exchange.asmx");
}
catch (Exception ex)
{
throw new Exception(string.Format("WebService Uri:" + ex));
}
//Credentials
try
{
exchangeService.Credentials = new WebCredentials("[email protected]", "pwd", "domain");
}
catch (Exception ex)
{
throw new Exception(string.Format("Credentials:" + ex));
}
//Send a mail
try
{
EmailMessage message = new EmailMessage(exchangeService);
message.Subject = "Test";
message.Body = "Test";
message.ToRecipients.Add("[email protected]");
message.Save();
message.Send();
}
catch (Exception ex)
{
throw ex;
}
この問題に関するこのサイトの他の記事を読んだが、問題を解決できなかった。これを変更
あなたはこの質問をして私のキャリアを救った! – Chookoos
私の喜び:)! – GwenGuts
EWS接続が以前に動作し、動作していない状況では、パスワードが期限切れのように単純なものになり、変更する必要があります。 – RenniePet