1

EWS API を使用して予定をユーザーの交換カレンダーにエクスポートしています。正常に動作していましたが、予定で、テーブルの配置などでhtmlが適切にフォーマットされていないことに気付きました。そのため、予定の本文の種類のプロパティを HTML に設定しようとしましたが、プロパティを設定した行で「値を読み取る前に、このプロパティを読み込むか割り当てる必要があります」という ServiceObjectPropertyException が発生しました。

                User SelectedUser = UserController.GetExchangeCredentials(UserID);

                //If they have their exchange credentials setup then create the appointment in their exchange calender
                if (SelectedUser.ExchangeUsername != String.Empty)
                {
                    Client ClientInfo = ClientController.GetContactInfoForCalenderAppointment(int.Parse(btn_SubmitNextContactDate.CommandArgument.ToString()), int.Parse(ddl_Contact.SelectedValue));

                    //Setup the exchange service with the user credentials of that receiving the appointment
                    ExchangeService Service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                    Service.UseDefaultCredentials = false;
                    Service.Credentials = new WebCredentials(SelectedUser.ExchangeUsername, SelectedUser.ExchangePassword, SelectedUser.ServerDomain);
                    Service.AutodiscoverUrl(SelectedUser.Email);

                    //Create the appointment
                    Microsoft.Exchange.WebServices.Data.Appointment Appointment = new Microsoft.Exchange.WebServices.Data.Appointment(Service);
                    Appointment.Body.BodyType = BodyType.HTML;
                    Appointment.Subject = "Next Contact Date for " + OperatingName.Text;                        
                    Appointment.Body = "<table><tr><td><b>Client Name:</b></td><td>" + ClientName.Text + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Operating Name:</b></td><td>" + OperatingName.Text + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Service:</b></td><td>" + ddl_ServiceType.SelectedItem.Text + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Contact Method:</b></td><td>" + ddl_ContactMethod.SelectedItem.Text + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Contact Name:</b></td><td>" + ddl_Contact.SelectedItem.Text + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Contact Phone:</b></td><td>" + ClientInfo.Contacts[0].Phone + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Contact Email:</b></td><td>" + ClientInfo.Contacts[0].Email + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Client Address 1:</b></td><td>" + ClientInfo.Address1 + "</td></tr>";
                    Appointment.Body += "<tr><td><b>Note:</b></td><td>" + txt_NextContactDateNote.Content + "</td></tr></table>";
                    Appointment.Start = DateTime.Parse(txt_NextContactDate.Text);
                    Appointment.End = DateTime.Parse(txt_NextContactDate.Text);
                    Appointment.Save(SendInvitationsMode.SendToNone);
                }                
4

1 に答える 1

1

これは、Exchange 2010 SP1 では問題なく動作します...テストするExchange 2007 SP1がありません。

Appointment appt = new Appointment(service)
{
    Subject = "Next Contact Date",
    Body = new MessageBody()
    {
        BodyType = BodyType.HTML,
        Text = "here is some body content. <b>this is bold</b>" +
              "<table><tr><td><b>Client name: </b></td><td>George</td></tr></table>",
    },
    Start = DateTime.Now.AddDays(1),
    End = DateTime.Now.AddDays(1).AddHours(.5),
};
appt.Save();
于 2012-08-22T16:52:40.403 に答える