交换Web服务

时间:2014-01-31 12:49:56

标签: asp.net exchangewebservices

我正在失去理智,因为它是通过交换webservices和asp.net发送预约的最后一点申请。

2错误取决于我使用的代码段:所以如果我使用:

   service.AutodiscoverUrl("Admin@test.com");

我收到错误:"The account does not have permission to impersonate the requested user"

如果我使用

    service.Url = new Uri("https://test.com/OWA/Exchange.asmx")

我收到错误“请求失败。The remote server returned an error: (440) Login Timeout.

我可以使用该帐户在Web Outlook上正常登录,因此我知道它可以工作,我也可以在使用System.NEt.mail时从应用程序接收电子邮件

                 public static void SendOutLookAppointment(string email)
    {

        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
       // //service.UseDefaultCredentials = true;
        service.Credentials = new WebCredentials("Admin@test.com"", "password");

        //service.AutodiscoverUrl("Admin@test.com");

        service.Url = new Uri("https://webmail.test.com/EWS/Exchange.asmx");

        //service.Credentials = new WebCredentials("Admin@test.com"", "password");
        //service.AutodiscoverUrl("Admin@test.com", RedirectionUrlValidationCallback);

        ImpersonatedUserId i = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "project.management@za.man-mn.com");
        service.ImpersonatedUserId = i;

        Appointment appointment = new Appointment(service);
        appointment.Subject = "Calendar booking via WebService";
        appointment.Body = "This is a test";
        appointment.Start = new DateTime(2014,02,03, 21, 0, 0);
        appointment.End = new DateTime(2014,02,02,22,0, 0);

        appointment.RequiredAttendees.Add(email);


         appointment.Save();
    }

0 个答案:

没有答案