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

مشاهدة النسخة كاملة : Microsoft.Exchange.WebServices Question



C# Programming
03-19-2010, 05:18 AM
I am testing out using Exchange Webservices to post tasks to the current user in a corporate intranet.
The code below works when I run it through Visual Studio 2008 debug mode, but when I publish it to the intranet site, it bails with the following error:

Microsoft.Exchange.WebServices.Data.ServiceResponseException:
When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.

I have disabled anonymous access to the website and have it set security to Integrated Windows Authentication.
As you can see below, I am passing the default credentials to the web service.

What am I missing here?http://www.barakasoft.com/script/Forums/Images/smiley_confused.gif
Any help will be appreciated.

public class ExchangeTask
{
ExchangeService myService = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
public ExchangeTask()
{
ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
// Trust all certificates. WARNING: Don't do this in production code!
return true;
};
myService.UseDefaultCredentials = true;
myService.AutodiscoverUrl(EmailAddressToFind);
ServiceURL = myService.Url.ToString();
}

public void SendTask()
{
Task myTask = new Task(myService);

myTask.Body = "This is a reminder task that has automatically been set by ExchangeWebservices";
myTask.DueDate = DateTime.Now;
myTask.ReminderDueBy = DateTime.Now;
myTask.StartDate = DateTime.Now;
myTask.Subject = "Event Reminder Task";
myTask.Save();
}