Thursday, 15 August 2013

How to save an outlook appointment in users calendar?

How to save an outlook appointment in users calendar?

I am developing an asp.net web application which allows users to syn any
Event from the gridView to there Outlook appointment using the following
code:
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();
}
Code works fine when I run locally in visual studio localhost, but fails
on server. Not sure logically would it be able to store an outlook
appointment on client outlook since the code is running at server.
Please point me to right direction, even in case I need to use different
approach.
Thanks in advance.

No comments:

Post a Comment