So I've been looking into programmatically creating calendar events for the Outlook Calendar.
I looked at the documentation here and here.
Are there any step-by-steps regarding asp.net webforms to display on .ASPX pages or exemplars of code targeted for that domain.
I tried following this example in adding an appointment to the calendar but I receive the error 'HttpApplicationState does not contain a definition for 'CreateItem' and no accessible extension method 'CreateItem' accepting a first argument of type 'HttpApplicationState' could be found (are you missing a using directive or an assembly reference?)
private void AddAppointment()
{
try
{
Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)
Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
newAppointment.Start = DateTime.Now.AddHours(2);
newAppointment.End = DateTime.Now.AddHours(3);
newAppointment.Location = "ConferenceRoom #2345";
newAppointment.Body = "We will discuss progress on the group project.";
newAppointment.AllDayEvent = false;
newAppointment.Subject = "Group Project";
newAppointment.Recipients.Add("Roger Harui");
Outlook.Recipients sentTo = newAppointment.Recipients;
Outlook.Recipient sentInvite = null;
sentInvite = sentTo.Add("Holly Holt");
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olRequired;
sentInvite = sentTo.Add("David Junca ");
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olOptional;
sentTo.ResolveAll();
newAppointment.Save();
newAppointment.Display(true);
}
catch (Exception ex)
{
Console.WriteLine("The following error occurred: " + ex.Message);
}
}
These are my using's:
using System;
using Outlook = Microsoft.Office.Interop.Outlook;
Have I just come at this completely wrong?
EDIT #1: I want to integrate the outlook calendar into the website so that users can add an appointment to their outlook calendar. I'm looking for concise documentation to achieve this in C# on an ASP.NET webforms site, and most of the documentation is for Microsoft.Office.Interop which doesn't seem to work locally for me.