المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problems with Exchange WebService API



C# Programming
02-20-2010, 03:00 AM
Hi there

I can't get Exchange webservice for Exchange 2007 SP1 working

http://msdn.microsoft.com/en-us/library/bb408417%28EXCHG.80%29.aspx[^ (http://msdn.microsoft.com/en-us/library/bb408417%28EXCHG.80%29.aspx)]

when I run the following C# code:


ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials(@"username", "password", "domain");
//(obviously in my code i am using the correct credentials)
service.AutodiscoverUrl("username@domain.co.za");


FindItemsResults findResults =
service.FindItems(WellKnownFolderName.Inbox,new ItemView(10));
foreach (Item item in findResults.Items)
{
// Do something with the item.
}

It get this error:

Request failed. The remote server returned an error: (401) Unauthorized.

Any help will be greatly appreciate !!

Thanks in advance.