【发布时间】:2018-11-19 11:28:08
【问题描述】:
我正在尝试将新约会添加到使用“iCloud for Windows”链接的日历中。我已经阅读了我在这个站点上可以找到的关于 Outlook 和日历主题的所有内容,并且我使用 OutlookSpy 浏览了各种对象和文件夹,(我感谢 Dimitry 为这个神话般的工具为编码社区提供的巨大帮助)。
但是,我仍然无法写入非默认日历。
基于这个答案,Creating an appointment to a specific calendar. VBA outlook,这是我的代码...
using Microsoft.Office.Interop.Outlook
...
Application app = new Application();
AppointmentItem appt = null;
app.ActiveExplorer().CurrentFolder =
app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
Recipient recipent = app.Session.CreateRecipient("Jobs");
appt = app.CreateItem(OlItemType.olAppointmentItem);
appt.Subject = "Subject goes here ...";
appt.Location = "Address/Suburb/State";
appt.Body = "Job GPS: " + "-1234567 987654";
appt.Start = DateTime.Now;
appt.End = appt.Start.AddHours(2);
app.ActiveExplorer().CurrentFolder.Items.Add(appt); <--- Fails here
我不确定我要写入的日历是否是非 Outlook 日历,或者我只是在尝试保存约会之前遗漏了某些内容。
我们将不胜感激。
【问题讨论】: