I am using Aspose.Email assembly to check a mail server for any received mails in the inbox. But the emailClient.ListMessages(emailClient.MailboxInfo.InboxUri) method in the code below returns the following error,
Error:
The remote server returned an error: (405) Method Not Allowed.
Code:
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);
stack trace:
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()
EDIT
Aspose.Email.Exchange.ExchangeClient emailClient = new Aspose.Email.Exchange.ExchangeClient("MailserverUri", credential);
The MailserverUri i targeted was Exchange web service.
Finally i got it corrected…..
ExchangeWebServiceClient should be used in case of Exchange webservice. Use this class instead of ExchangeClient.The server url is also different in case of EWS.The code i used to overcome the error is as follows,
For further details do check the link below,
http://www.aspose.com/community/forums/thread/301094/405-method-not-allowed-while-connecting-to-exchange-web-service.aspx