C# outlook interop 将会议保存为约会问题

C# outlook interop saving meeting as appointment issues

我正在尝试将 Outllok 会议 ics 文件另存为 Outlook 约会 ics,但是当我对文件夹位置使用 do SaveAs 时,它正在另存为会议。

我有以下代码,但我似乎找不到问题所在。当我使用 .Display 时,它显示为约会,但 .SaveAs 正在保存为与收件人的会议。

非常感谢任何帮助

Outlook.Application App = new Outlook.Application();
string FPath = @"C:\Documents\TestMeeting.ics"
var item = App.Session.OpenSharedItem(FPath) as Outlook.MeetingItem;
var AppointmentItem = item.GetAsssociatedAppointment(false);

AppointmentItem.MeetingStatus = Outlook.OlMeetingStatus.olNonMeeting;
AppointmentItem.Display(true);
AppointmentItem.SaveAs(@"C:\Documents\TestAppointment1.ics",Outlook.OlSaveAsType.olIcal);

使用Save方法将刚刚打开的会议保存到您的日历中:

string FPath = @"C:\Documents\TestMeeting.ics"
var item = App.Session.OpenSharedItem(FPath) as Outlook.MeetingItem;
item.Save();
// only after that you can try reprieving the associated appointment
var AppointmentItem = item.GetAsssociatedAppointment(false);

另外,我建议您从头开始创建一个新的约会项目,然后将其保存到磁盘。

谢谢尤金。我设法通过创建新约会并使用相关约会的 .BodyFormat 和 .RTFBody 来完成这项工作。我已经为将来的任何人提供了下面的完整代码,并将您的答案标记为正确。抱歉,但目前我没有足够的代表来投票,否则我会的。非常感谢

Outlook.Application App = new Outlook.Application();
string FPath = @"C:\Documents\TestMeeting.ics"
var item = App.Session.OpenSharedItem(FPath) as Outlook.MeetingItem;
var AppointmentItem = item.GetAsssociatedAppointment(false);
Outlook.AppointmentItem ap1 = (Outlook.AppointmentItem)App.CreateItem(Outlook.OlItemType.olAppointmentItem);
ap1.Start = AppointmentItem.Start;
ap1.Subject = AppointmentItem.Subject;
ap1.BodyFormat = AppointmentItem.BodyFormat;
ap1.RTFBody = AppointmentItem.RTFBody;
ap1.Location = AppointmentItem.Location;
ap1.SaveAs(@"C:\Documents\TestAppointment1.ics",Outlook.OlSaveAsType.olIcal);