404 Bad Request

I’m trying to execute a call to this method:

ExchangeClient.ListMessages()

My code looks like this:

string mailboxUri = “http://servername/exchange/user”; //mailbox uri
string username = “MY USER NAME”;
string password = “MY PASSWORD”;
string domain = “MY DOMAIN”; // have tried fully qualifying this also

NetworkCredential credential = new NetworkCredential(username, password, domain);

//create an exchangeclient
ExchangeClient client = new ExchangeClient(mailboxUri, credential);
try
{
//query mailbox
ExchangeMailboxInfo mailbox = client.GetMailboxInfo();
//list messages in the Inbox
ExchangeMessageInfoCollection messages = client.ListMessages(mailbox.InboxUri, false);

foreach (ExchangeMessageInfo info in messages)
{
Console.WriteLine("From: " + info.From);
Console.WriteLine("Subject: " + info.Subject);
}
}
catch (ExchangeException ex)
{
Console.WriteLine(ex.ToString());
}

this code is the same as the example from the demo files and throws an exception at the message call as stated. 404 bad request.

I’ve tried this as a asp.net application and as a desktop/console app, no joy. I’m running this code on a windows server machine (sp2, 32 bit) running .NET 2.0 and using exchange 2003, using the aspose dll file version 4.6.0.1 (2.0)

Stack Trace:

System.Net.WebException was unhandled by user code Message=“The remote server returned an error: (400) Bad Request.” Source=“Aspose.Network” StackTrace: at Aspose.Network.Exchange.ExchangeClient.x02b56011810c316c(String x8b5b49efcd08ae0a, String x196c05a09a123da6) at Aspose.Network.Exchange.ExchangeClient.ListMessages(String folder, Boolean recursive) at _Default.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\matt.ferron\My Documents\Visual Studio 2005\WebSites\TestAspose\Default.aspx.cs:line 33 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Does anyone have any idea why this is happening?

Hi Matt,

Thanks for considering Aspose.

We are looking into it. Sorry for some delay. We will get back to you shortly.

Hi,

Are you able to access the Exchange mailbox from Microsoft Outlook? Aspose.Network should not have any problem if you can send/receive messages from Microsoft Outlook using the same credentials.

Of course I can. Don’t worry, I’m implementing this project using other software. Thanks for your effort.