0

我正在使用Aspose.Email程序集来检查邮件服务器的收件箱中是否有任何收到的邮件。但是下面代码中的emailClient.ListMessages(emailClient.MailboxInfo.InboxUri)方法返回如下错误,

错误:

The remote server returned an error: (405) Method Not Allowed.

代码:

System.Net.NetworkCredential credential = new System.Net.NetworkCredential("username", "password", "domainname");

Aspose.Email.Exchange.ExchangeClient emailClient = new Aspose.Email.Exchange.ExchangeClient("MailserverUri", credential);

Aspose.Email.Exchange.ExchangeMessageInfoCollection messageInfoCollection = emailClient.ListMessages(emailClient.MailboxInfo.InboxUri);

堆栈跟踪:

 at Aspose.Email.Exchange.ExchangeClient.GetMailboxInfo(String mailbox)
 at Aspose.Email.Exchange.ExchangeClient.GetMailboxInfo()
 at Aspose.Email.Exchange.ExchangeClient.get_MailboxInfo()
 at ACS.PMO.MainForm.ProcessAction() in D:\Projects\MainForm.cs:line 54
 at ACS.PMO.ClientService.MCPClient.ExecuteProcess()

编辑

Aspose.Email.Exchange.ExchangeClient emailClient = new Aspose.Email.Exchange.ExchangeClient("MailserverUri", credential);

我针对的MailserverUri是 Exchange Web 服务。

4

1 回答 1

0

最后我把它改正了......

ExchangeWebServiceClient 应在 Exchange Web 服务的情况下使用。使用此类而不是 ExchangeClient。在 EWS 的情况下,服务器 url 也不同。我用来克服错误的代码如下,

 ExchangeWebServiceClient client = new ExchangeWebServiceClient("https://exchange-server-host/ews/Exchange.asmx", "username", "password", "domain");

有关更多详细信息,请查看以下链接,

http://www.aspose.com/community/forums/thread/301094/405-method-not-allowed-while-connecting-to-exchange-web-service.aspx

于 2012-06-06T08:22:36.490 回答