Reputation: 15
I have a local web page in which domain user adds appointment through the page( entering details such as subject, body, start end date etc.) and saves to database.
I want to add the appointment to the client's Outlook calendar at the same time silently (without prompting for ics file save/open ).
I use following function to add to calendar with a new generated GUID:
protected void sendToOutlook(Guid outlook_ID)
{
_Application olApp = (_Application)new Application();
NameSpace mapiNS = olApp.GetNamespace("MAPI");
string profile = email;
mapiNS.Logon(profile, null, null, null);
_AppointmentItem apt = (_AppointmentItem)
olApp.CreateItem(OlItemType.olAppointmentItem);
// set some properties
apt.Subject = txtSubject.Text;
apt.Body = txtDetail.Text;
apt.Start = Convert.ToDateTime(txtStart.Text + " " + ddStartHour.SelectedValue);// new DateTime(2014, 10, 21, 14, 00, 00);
apt.End = Convert.ToDateTime(txtEnd.Text + " " + ddEndHour.SelectedValue);
DateTime dt = new DateTime(2014, 10, 21, 14, 00, 00);
apt.ReminderMinutesBeforeStart = 15; // Number of minutes before the event for the remider
apt.BusyStatus = OlBusyStatus.olTentative; // Makes it appear bold in the calendar
apt.AllDayEvent = false;
apt.Location = txtLocation.Text;
apt.RequiredAttendees = email + ";" + txtAttendee.Text;
apt.UserProperties.Add("UID", OlUserPropertyType.olText);
apt.UserProperties["UID"].Value = outlook_ID.ToString();
apt.Close(OlInspectorClose.olSave);
}
This works on local perfectly but not working on server side. No error or warning, simply not responds. Could anyone tell me why?
Upvotes: 0
Views: 700
Reputation: 156978
You shouldn't use Office interop in a ASP.NET server process. Microsoft strongly dis-recommends it, for specifically this reason: unexpected behavior:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are using any modern version of Exchange, use the Exchange web service, which is very easy to use. I am not familiar with other platforms and their SDK's.
Another issue is probably that you are not writing in the user's calendar, but in the one of the user account responsible for running the web server.
Upvotes: 1