EWS托管API 2.0标识格式错误

时间:2018-01-25 03:36:00

标签: c# asp.net asp.net-mvc exchange-server exchangewebservices

我正在使用EWS Managed API 2.0发送会议邀请并捕获用户响应。

我已关注官方网站https://msdn.microsoft.com/en-us/library/office/jj220499(v=exchg.80).aspx的参考资料 和https://msdn.microsoft.com/en-us/library/office/dd633661(v=exchg.80).aspx。我正在收到错误,因为我的格式错误。

我使用了官方网站上的确切代码。我做了一些谷歌搜索,发现如果id有特殊字符,可能会出现此错误。但我提供的身份证没有特殊性,只是一个简单的角色。

这是代码

ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            service.Credentials = new WebCredentials("********@live.com", "************");

            service.TraceEnabled = true;
            service.TraceFlags = TraceFlags.All;

            service.AutodiscoverUrl("***********@live.com", RedirectionUrlValidationCallback);

            // Create the appointment.

            Appointment appointment = Appointment.Bind(service, "AAMkA=");


            // Set properties on the appointment. Add two required attendees and one optional attendee.
            appointment.Subject = "Status Meeting";
            appointment.Body = "The purpose of this meeting is to discuss status.";
            appointment.Start = new DateTime(2009, 3, 1, 9, 0, 0);
            appointment.End = appointment.Start.AddHours(2);
            appointment.Location = "Conf Room";
            appointment.RequiredAttendees.Add("***********@live.com");

            // Send the meeting request to all attendees and save a copy in the Sent Items folder.
            appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

            foreach (Attendee t in appointment.RequiredAttendees)
            {
                if (t.ResponseType != null)
                    Console.WriteLine("Required attendee - " + t.Address + ": " + t.ResponseType.Value.ToString());
            }

Appointment appointment = Appointment.Bind(service, "AAMkA=");中收到错误ID已发生故障。

id as malfunction

2 个答案:

答案 0 :(得分:0)

给出错误的代码行用于删除/取消会议I.E.在您拨打appointment.Delete()

之前,使用它的唯一标识符绑定到现有约会
Appointment appointment = Appointment.Bind(service, "AAMkA=");

将以上行更改为:

Appointment appointment = new Appointment(service);

答案 1 :(得分:0)

Exchange服务器将在创建约会时提供唯一ID。 因此,需要保存Id并在获取用户响应时传递相同的Id。

var Id = appointment.Id;

所以传递Id以获取响应。