The first and foremost thing in creating a Appointment is to Add reference to the library, Microsoft.Office.Interop.Outlook.dll. Find how to download here.
Once done with referencing the Library to your forms application , Use the Library by adding the code,
Done with all these steps ?? Creating an meeting Appointment is easy !!!.
Add the Following piece of code,to create an appointment./// this represents the entire outlook application.
Outlook.Application Application = new Outlook.Application();
/// Create a new appointment.
Outlook.AppointmentItem newAppointment =(Outlook.AppointmentItem)
Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
/// Set the Start and End date of the appointment.
newAppointment.Start =DateTime.Now;
newAppointment.End = DateTime.Now.AddDays(1);
/// Set the all-day event property.
newAppointment.AllDayEvent = false;
/// set the Location,Subject and Body of the Appointment.
newAppointment.Location ="TestLocation";
newAppointment.Subject="Meeting";
newAppointment.Body="Appointment body";
/// set the Busy status during the time period
newAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olFree;
newAppointment.Save();
The appointment will be saved in your calendar.
Note:- Do not Create an All day event unless necessary.
Want to send Invitee to others ??
Add the Code below
///create Recipients for the meeting request.
Outlook.Recipients sendTo = newAppointment.Recipients;
/// Add invitee's.
Outlook.Recipient sentInvite = null;
sentInvite = sentTo.Add("Dave@Example.com"); // Email of the Invitee.
// Recipient type Required.
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olRequired;
sentInvite = sentTo.Add("Dave@Example.com"); // Email of the Invitee.
// Recipient type Optional
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olOptional;
/// set the meeting Status.
newAppointment.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
///resolve the names against your Contacts.
sentTo.ResolveAll();
///Send the meeting request.
((Outlook._AppointmentItem)newAppointment).Send();
Meeting invite ll be sent to the recipients.
That's it, Done !!!!
for more details refer,
No comments:
Post a Comment