如何在用户日历中保存Outlook预约?

时间:2013-08-15 21:39:52

标签: c# asp.net outlook

我正在开发一个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约会。

请指出正确的方向,即使我需要采用不同的方法。

提前致谢。

2 个答案:

答案 0 :(得分:1)

Outlook,就像任何其他Office应用程序一样,不能在服务(例如IIS)中使用。 有关替代方案,请参阅How to access client's outlook in ASP.net?

答案 1 :(得分:0)

我总是将其作为电子邮件发送给用户。很多在线网站都有需要发送的电子邮件转换成会议请求所需的数据,这是一个例子。

http://sahannet.blogspot.com/2010/09/create-outlook-vcalendar-reminder-file.html