ExchangeClient - (440) Login Timeout

We are attempting to send an email via Exchange 2003 and the Aspose ExchangeClient class.


This server is using OWA with Forms-Based authentication, and it all works properly when using the browser.

When I call Send() on the ExchangeClient class, it throws an exception with the following:

The remote server returned an error: (440) Login Timeout.

I’ve tried everything I can, including looking into IIS settings and can not figure out why this is occurring.

Any suggestions?

Hi,

Sorry for delayed response.

Could you please check the following,

  • The mailbox URI is correct. It is often in the form of “[https://host-name/EWS/Exchange.asmx ](https://host-name/EWS/Exchange.asmx)
  • Try executing the program directly on the Exchange Server if possible. It is to check whether there is a firewall blocking or other network issue.
  • If you only hit the exception on Send(), try accessing the folder information or messages in any folder using same credentials.

If you have already checked the above then there could be something wrong with the source code, please check and test the below source code to connect with secured exchange server,

// Create Aspose Exchange Client
ExchangeClient client = new ExchangeClient(strURL, userID, password, domain);

client.CookieContainer = new CookieContainer();
client.CookieContainer.Add(AuthenticateSecureOWA(serverName, domain, userID, password));
ExchangeMailboxInfo mailbox = client.GetMailboxInfo();

//authenticate the secure outlook web access
private CookieCollection AuthenticateSecureOWA(string strServerName, string strDomain, string strUserName, string strPassword)
{
System.Uri AuthURL = null;

try
{
// Construct our destination URI.
AuthURL = new System.Uri(“https://” + strServerName + “/exchweb/bin/auth/owaauth.dll”);
Console.WriteLine("Authenticated against: " + AuthURL);
}
catch (Exception ex)
{
throw new Exception(“Error occurred while you are creating the URI for OWA authentication!\n\n” + ex.Message);
}

CookieContainer CookieJar = new CookieContainer();

// Create our request object for the constructed URI.
WebReq = (HttpWebRequest)WebRequest.Create(AuthURL);
WebReq.CookieContainer = CookieJar;

// Create our post data string that is required by OWA (owaauth.dll).
String strPostFields = “destination=https%3A%2F%2F” + strServerName + “%2Fexchange%2F” + strUserName + “%2F&username=” + strDomain + “%5C” + strUserName + “&password=” + strPassword + “&SubmitCreds=Log+On&forcedownlevel=0&trusted=0”;

WebReq.KeepAlive = true;
WebReq.AllowAutoRedirect = false;
WebReq.Method = “POST”;

// Store the post data into a byte array.
Byte[] PostData = System.Text.Encoding.ASCII.GetBytes(strPostFields);

// Set the content length.
WebReq.ContentLength = PostData.Length;

Stream tmpStream;

try
{
// Create a request stream. Write the post data to the stream.
tmpStream = WebReq.GetRequestStream();
tmpStream.Write(PostData, 0, PostData.Length);
tmpStream.Close();
}
catch (Exception ex)
{
throw new Exception(“Error occurred while trying OWA authentication!\n\n” + ex.Message);
}

// Get the response from the request.
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

WebResp.Close();
return WebResp.Cookies;
}

Reference : [KB891748 ](http://support.microsoft.com/kb/891748/en-us/)