我正在开发一个 asp.net Web 应用程序,它允许用户使用以下代码将任何事件从 gridView 同步到 Outlook 约会:
private void generateOutlookAppointment(string subject, string location, string startDate, string endDate)
{
string body = "Test Data for Body.";
Outlook.Application outlookApp = new Outlook.Application();
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = subject;
oAppointment.Body = body ;
oAppointment.Location = location;
oAppointment.Start = DateTime.Parse(startDate).AddHours(9);
oAppointment.End = DateTime.Parse(endDate).AddHours(9);
oAppointment.ReminderSet = true;
oAppointment.ReminderMinutesBeforeStart = 15;
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;
oAppointment.Save();
}
当我在 Visual Studio localhost 中本地运行时,代码工作正常,但在服务器上失败。由于代码在服务器上运行,因此在逻辑上不确定是否能够在客户端 Outlook 上存储 Outlook 约会。
请指出我正确的方向,即使我需要使用不同的方法。
提前致谢。