Exemplo n.º 1
0
        public void CreateOutlookAppointments()
        {
            var a = new Outlook.Application();

            Outlook.AppointmentItem appointment = (Outlook.AppointmentItem)a.CreateItem(Outlook.OlItemType.olAppointmentItem);

            appointment.Subject    = "Feierabend";
            appointment.Start      = DateTime.Now;
            appointment.End        = appointment.Start.Date.AddDays(1);
            appointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
            appointment.ReminderMinutesBeforeStart = 15;
            appointment.ReminderSet = true;
            appointment.Save();
        }
Exemplo n.º 2
0
        private ArrayList RecurringItems()
        {
            // Filter all the objects we are looking for.
            Outlook.AppointmentItem appoinmentItem = null;
            Outlook.MAPIFolder      folder         = OutlookApplication.Session.GetDefaultFolder(
                Outlook.OlDefaultFolders.olFolderCalendar)
                                                     as Outlook.MAPIFolder;
            // Use a Jet Query to filter the details we need initially between
            // the two spcified dates.
            string dateFilter = String.Format(
                CultureConstants.DefaultCulture,
                "[Start] >= '{0:g}' and [End] <= '{1:g}'",
                startDate,
                endDate);

            Outlook.Items calendarItems = folder.Items.Restrict(dateFilter);
            calendarItems.Sort("[Start]", Type.Missing);
            calendarItems.IncludeRecurrences = true;

            // Must use 'like' comparison for Find/FindNext
            string subjectFilter = String.Empty;

            if (String.IsNullOrEmpty(subject))
            {
                subjectFilter = "@SQL="
                                + "\"" + "urn:schemas:httpmail:subject" + "\""
                                + " like '%" + subject + "%'";
            }
            else
            {
                subjectFilter = "@SQL="
                                + "\"" + "urn:schemas:httpmail:subject" + "\""
                                + " <> '!@#'";
            }
            // Use Find and FindNext methods to get all the items.
            ArrayList resultArray = new ArrayList();

            appoinmentItem = calendarItems.Find(subjectFilter)
                             as Outlook.AppointmentItem;
            while (appoinmentItem != null)
            {
                resultArray.Add(appoinmentItem);
                // Find the next appointment.
                appoinmentItem = calendarItems.FindNext()
                                 as Outlook.AppointmentItem;
            }
            return(resultArray);
        }
Exemplo n.º 3
0
        public override bool GetAppointment(int iIndex)
        {
            if (iIndex > appointmentArray.Count - 1)
            {
                return(false);
            }
            if (iIndex < 0)
            {
                return(false);
            }

            appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];
            startDate       = appointmentItem.Start;
            endDate         = appointmentItem.End;
            subject         = appointmentItem.Subject;
            reminder        = appointmentItem.ReminderSet;
            minutes         = appointmentItem.ReminderMinutesBeforeStart;
            entryID         = appointmentItem.EntryID;
            return(true);
        }
Exemplo n.º 4
0
        public override void UpdateAppointment(int iIndex)
        {
            appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];

            appointmentItem.Subject = subject;
            appointmentItem.Start   = startDate;
            appointmentItem.End     = endDate;
            appointmentItem.Body    = String.Format(CultureConstants.DefaultCulture, "{0} \r\nUpdated: {1}", appointmentItem.Body, DateTime.Now);

            appointmentItem.ReminderSet = reminder;
            if (reminder)
            {
                appointmentItem.ReminderMinutesBeforeStart = minutes;
            }
            else
            {
                appointmentItem.ReminderMinutesBeforeStart = 0;
            }

            appointmentItem.BusyStatus  = Outlook.OlBusyStatus.olBusy;
            appointmentItem.AllDayEvent = false;
            appointmentItem.Location    = String.Empty;

            if (alternateReminder)
            {
                earlyReminder = new DateTime(startDate.Year, startDate.Month, startDate.Day, earlyReminder.Hour, earlyReminder.Minute, earlyReminder.Second);
                lateReminder  = new DateTime(startDate.Year, startDate.Month, startDate.Day, lateReminder.Hour, lateReminder.Minute, lateReminder.Second);

                DateTime dtReminder = WorkOutAlternateReminders();
                // Subtract the reminder time from the appointment time.
                TimeSpan timeSpan = appointmentItem.Start.Subtract(dtReminder);
                appointmentItem.ReminderMinutesBeforeStart = Math.Abs((timeSpan.Hours * 60) + timeSpan.Minutes);
                minutes = appointmentItem.ReminderMinutesBeforeStart;
            }
            appointmentItem.Save();
        }
Exemplo n.º 5
0
 public override void DeleteAppointment(int iIndex)
 {
     appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];
     appointmentItem.Delete();
 }
Exemplo n.º 6
0
        public override void UpdateAppointment(int iIndex)
        {
            appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];

            appointmentItem.Subject = subject;
            appointmentItem.Start = startDate;
            appointmentItem.End = endDate;
            appointmentItem.Body = String.Format(CultureConstants.DefaultCulture, "{0} \r\nUpdated: {1}", appointmentItem.Body, DateTime.Now);

            appointmentItem.ReminderSet = reminder;
            if (reminder)
                appointmentItem.ReminderMinutesBeforeStart = minutes;
            else
                appointmentItem.ReminderMinutesBeforeStart = 0;

            appointmentItem.BusyStatus = Outlook.OlBusyStatus.olBusy;
            appointmentItem.AllDayEvent = false;
            appointmentItem.Location = String.Empty;

            if (alternateReminder)
            {
                earlyReminder = new DateTime(startDate.Year, startDate.Month, startDate.Day, earlyReminder.Hour, earlyReminder.Minute, earlyReminder.Second);
                lateReminder = new DateTime(startDate.Year, startDate.Month, startDate.Day, lateReminder.Hour, lateReminder.Minute, lateReminder.Second);

                DateTime dtReminder = WorkOutAlternateReminders();
                // Subtract the reminder time from the appointment time.
                TimeSpan timeSpan = appointmentItem.Start.Subtract(dtReminder);
                appointmentItem.ReminderMinutesBeforeStart = Math.Abs((timeSpan.Hours * 60) + timeSpan.Minutes);
                minutes = appointmentItem.ReminderMinutesBeforeStart;
            }
            appointmentItem.Save();
        }
Exemplo n.º 7
0
        public override bool GetAppointment(int iIndex)
        {
            if (iIndex > appointmentArray.Count - 1)
                return false;
            if (iIndex < 0)
                return false;

            appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];
            startDate = appointmentItem.Start;
            endDate = appointmentItem.End;
            subject = appointmentItem.Subject;
            reminder = appointmentItem.ReminderSet;
            minutes = appointmentItem.ReminderMinutesBeforeStart;
            entryID = appointmentItem.EntryID;
            return true;
        }
Exemplo n.º 8
0
 public override void DeleteAppointment(int iIndex)
 {
     appointmentItem = (Outlook.AppointmentItem)appointmentArray[iIndex];
     appointmentItem.Delete();
 }