私はMicrosoft.Office.Interop.Outlookを使用して、予定をインターフェイスに読み込んで予定を編集しています。予定を完全に読み込めます。編集は機能しますが、100%はできません。場合によってはエラーが発生するThe operation cannot be performed because the message has been changed
プログラムで予定を編集する
The operation cannot be performed because the message has been changed
のエラーを回避するために、予定を編集する方が良い方法があるのでしょうか。まずSave()
public Outlook.AppointmentItem EditOutlookAppointment(CustomAppointment appointment, int retries = 0)
{
Outlook.AppointmentItem appointReturned = null;
try
{
Outlook.Application outlookApp = new Outlook.Application();
MAPIFolder calendarFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
for (int i = calendarFolder.Items.Count; i > 0; i--)
{
var appointmentItem = ((Outlook.AppointmentItem)calendarFolder.Items[i]);
if (appointmentItem.GlobalAppointmentID == appointment.UniqueId)
{
// set some properties
appointmentItem.Subject = appointment.Subject;
appointmentItem.Body = appointment.Body;
appointmentItem.Location = appointment.Location; //Set the location
appointmentItem.Start = appointment.Start;
appointmentItem.End = appointment.End;
appointmentItem.Save();
return appointmentItem;
}
}
}
catch (Exception ex)
{
//Error message implementation here
}
return appointReturned;
}
どのような行にエラーメッセージが表示されますか? –
Updated @Sylverac – Master