[英]How to delete an appointment on someone else outlook calendar and sending a cancellation notice in c#
我正在構建一個調度程序面試管理應用程序,當在調度程序中插入新約會時,我將新約會設置給發送它的人和接收它的人,第一部分是我我將所謂的約會作為 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);
}
這是我用來取消約會的代碼,但它只對我取消(我在我的 PC 上使用 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();
}
}
非常感謝任何幫助
你應該使用app.Send();
在app.Delete();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.