private OutlookTasksWrapper DeleteTasksFromOutlook(List <ReminderTask> reminderTasks, List <ReminderTask> deletedTasks) { var disposeOutlookInstances = false; Application application = null; NameSpace nameSpace = null; try { // Get Application and Namespace GetOutlookApplication(out disposeOutlookInstances, out application, out nameSpace, ProfileName); foreach (var calendarAppointment in reminderTasks) { try { TaskItem taskItem = null; taskItem = nameSpace.GetItemFromID(calendarAppointment.TaskId) as TaskItem; if (taskItem != null) { taskItem.Delete(); Marshal.FinalReleaseComObject(taskItem); deletedTasks.Add(calendarAppointment); } } catch (Exception exception) { Logger.Error(exception); } } } catch (Exception exception) { Logger.Error(exception); return(new OutlookTasksWrapper { WaitForApplicationQuit = disposeOutlookInstances, Success = false }); } finally { //Close and Shutdown if (disposeOutlookInstances) { nameSpace.Logoff(); } Marshal.FinalReleaseComObject(nameSpace); nameSpace = null; if (disposeOutlookInstances) { // Casting Removes a warninig for Ambigous Call application.Quit(); Marshal.FinalReleaseComObject(application); } application = null; GC.Collect(); GC.WaitForPendingFinalizers(); } return(new OutlookTasksWrapper { WaitForApplicationQuit = disposeOutlookInstances, Success = true }); }
public void RemoveItem(IContext context, string path, bool recurse) { _item.Delete(); }
public void DeleteTask(TaskItem task) { Log.DebugFormat("Deleting task with subject '{0}'", task.Subject); task.Delete(); }
private static TaskItem createOrUpdateReminder(TaskItem item, Reminder reminder) { if (reminder.is_deleted != null && reminder.is_deleted.CompareTo("0") != 0 && reminder.is_deleted.ToLower().CompareTo("false") != 0) { item.Delete(); return(null); } if (item.UserProperties.Find(ASPEC_REMINDER_UUID) == null) { item.UserProperties.Add(ASPEC_REMINDER_UUID, OlUserPropertyType.olText, true, true); } item.UserProperties[ASPEC_REMINDER_UUID].Value = reminder.uuid; if (item.UserProperties.Find(ASPEC_REMINDER_FLAG) == null) { item.UserProperties.Add(ASPEC_REMINDER_FLAG, OlUserPropertyType.olYesNo, true, true); } item.UserProperties[ASPEC_REMINDER_FLAG].Value = true; item.Subject = reminder.subject; if (reminder.start_date != null) { item.StartDate = DateTime.ParseExact(reminder.start_date, "yyyy-MM-dd", null); } if (reminder.end_date != null) { item.DueDate = DateTime.ParseExact(reminder.end_date, "yyyy-MM-dd", null); } if (reminder.priority_id != null) { item.Importance = getPriority(reminder.priority_id.Value).Value; } if (reminder.status_id == 0) { item.Status = OlTaskStatus.olTaskNotStarted; } else if (reminder.status_id == 1) { item.Status = OlTaskStatus.olTaskInProgress; } else if (reminder.status_id == 2) { item.Status = OlTaskStatus.olTaskComplete; } else if (reminder.status_id == 3) { item.Status = OlTaskStatus.olTaskWaiting; } else if (reminder.status_id == 4) { item.Status = OlTaskStatus.olTaskDeferred; } item.Body = reminder.notes; if (item.UserProperties.Find(ASPEC_REMINDER_EMAIL_NOTIFICATION_VALUE) == null) { item.UserProperties.Add(ASPEC_REMINDER_EMAIL_NOTIFICATION_VALUE, OlUserPropertyType.olText, true, true); } item.UserProperties[ASPEC_REMINDER_EMAIL_NOTIFICATION_VALUE].Value = reminder.email_notification_value; if (item.UserProperties.Find(ASPEC_REMINDER_EMAIL_NOTIFICATION_UNIT) == null) { item.UserProperties.Add(ASPEC_REMINDER_EMAIL_NOTIFICATION_UNIT, OlUserPropertyType.olText, true, true); } item.UserProperties[ASPEC_REMINDER_EMAIL_NOTIFICATION_UNIT].Value = reminder.email_notification_unit; item.Save(); return(item); }
public void Delete() { _item.Delete(); }