我正在构建一个调度程序面试管理应用程序,当在调度程序中插入新约会时,我将新约会设置为发送它的人和正在接收它的人,第一部分是我将所谓的约会发送到接收器作为Vcard,但我也想将它添加为日历对象,但我找不到如何使用MSDN信息。 这是我用来添加新约会的代码:
private void AddAppointment(Appointment NewAppointment, string MailTo)
{
Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application(); // creates new outlook app
Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem); // creates a new appointment
oAppointment.Subject = NewAppointment.Subject; // set the subject
oAppointment.Body = NewAppointment.Description; // set the body
oAppointment.Location = NewAppointment.Location; // set the location
oAppointment.Start = NewAppointment.Start; // Set the start date
oAppointment.End = NewAppointment.End; // End date
oAppointment.ReminderSet = true; // Set the reminder
oAppointment.RequiredAttendees = MailTo;
if (NewAppointment.HasReminder)
{
oAppointment.ReminderMinutesBeforeStart = Convert.ToInt32(NewAppointment.Reminder.TimeBeforeStart.TotalMinutes);
}
else
oAppointment.ReminderMinutesBeforeStart = 60;
// reminder time
oAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // appointment importance
oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
oAppointment.Save();
Microsoft.Office.Interop.Outlook.MailItem mailItem = oAppointment.ForwardAsVcal();
mailItem.To = MailTo;
mailItem.Send();
Thread.Sleep(5000);
CancellAppointment(oAppointment.GlobalAppointmentID);
}
这是我用来取消预约的代码,但它只取消给我(我在我的电脑上使用Outlook应用程序)但我也需要将其取消给其他人:
private void CancellAppointment(string AppointmentID)
{
Microsoft.Office.Interop.Outlook.Application OlApp = new Microsoft.Office.Interop.Outlook.Application();
NameSpace OlNamspace = OlApp.GetNamespace("MAPI");
MAPIFolder AppointmentFolder = OlNamspace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
AppointmentFolder.Items.IncludeRecurrences = true;
foreach (AppointmentItem app in AppointmentFolder.Items)
{
if (app.GlobalAppointmentID == AppointmentID)
{
app.MeetingStatus = OlMeetingStatus.olMeetingCanceled;
app.ForceUpdateToAllAttendees = true;
app.Delete();
}
}
非常感谢任何帮助