We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

405: Method Not Allowed on GetEWSClient

We recently updated our Aspose.Email.dll to version 4.4.0.0 in order to accommodate Exchange 2013.


If connecting to an Exchange 2013 instance, we have no issues. If we connect to previous versions of Exchange, we are getting this error, as if we need to set the Exchange version. I am willing to do this in my code, I just don’t see any examples of doing this.

Here is our code:

private static IEWSClient CreateEWSConnection()
{
clsEncryptor ende = new clsEncryptor();
TblCtSystemValues objMailSettings = new TblCtSystemValues();
string _hostname = objMailSettings.MailHostName;
if (_hostname.EndsWith("/") || _hostname.EndsWith("\"))
_hostname = _hostname.Remove(_hostname.Length - 1);
DataRow dr = TblCtUserProfile.GetADUserEmailInfo(clsSession.UserID).Rows[0];
string _emailUserId = dr[“ADUserName”].ToString();
string _domain = dr[“ADDomain”].ToString();
string _password = ende.DecodeDecrypt(dr[“ADPassword”].ToString());

return CreateEWSConnection(_emailUserId, _password, _domain, _hostname);
}

private static IEWSClient CreateEWSConnection(string UserId, string Password, string Domain, string ExchangeServer)
{
string _hostname = ExchangeServer;
string _emailUserId = UserId;
string _domain = Domain;
string _password = Password;
NetworkCredential credentials = new NetworkCredential(UserId, Password, Domain);
IEWSClient client = EWSClient.GetEWSClient(ExchangeServer, credentials);
return client;
}

The error is thrown on the highlighted line. Is this because it is assuming a specific version of Exchange?

Hi Joe,

Thank you for writing to Aspose suppor team.

The IEWSClient interface doesn’t require any extra information such as Exchange Server version for connecting to any type of servers. I usually carry out tests at my end with Exchange Server 2010 and sample code from HERE, and have never faced any issue as you have mentioned. Could you please provide us with a test account credentials on your server that we could use for testing this issue at our end? We’ll look into it and assist you further accordingly.