コード例 #1
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiCalendar calendar = new MapiCalendar("LAKE ARGYLE WA 6743", "Appointment", "This is a very important meeting :)", new DateTime(2012, 10, 2, 13, 0, 0), new DateTime(2012, 10, 2, 14, 0, 0));

            // ExStart:SavingTheCalendarItemAsMSG
            calendar.Save(dataDir + "CalendarItemAsMSG_out.Msg", AppointmentSaveFormat.Msg);
            // ExEnd:SavingTheCalendarItemAsMSG
        }
        public static void Run()
        {
            //ExStart: ModifyDeleteOccurrenceInRecurrence
            DateTime startDate = DateTime.Now.Date.AddHours(12);

            MapiCalendarEventRecurrence   recurrence = new MapiCalendarEventRecurrence();
            MapiCalendarRecurrencePattern pattern    = recurrence.RecurrencePattern = new MapiCalendarDailyRecurrencePattern();

            pattern.PatternType = MapiCalendarRecurrencePatternType.Day;
            pattern.Period      = 1;
            pattern.EndType     = MapiCalendarRecurrenceEndType.NeverEnd;

            DateTime exceptionDate = startDate.AddDays(1);

            // adding one exception
            pattern.Exceptions.Add(new MapiCalendarExceptionInfo
            {
                Location          = "London",
                Subject           = "Subj",
                OriginalStartDate = exceptionDate,
                StartDateTime     = exceptionDate,
                EndDateTime       = exceptionDate.AddHours(5)
            });
            pattern.ModifiedInstanceDates.Add(exceptionDate);
            // every modified instance also has to have an entry in the DeletedInstanceDates field with the original instance date.
            pattern.DeletedInstanceDates.Add(exceptionDate);

            // adding one deleted instance
            pattern.DeletedInstanceDates.Add(exceptionDate.AddDays(2));


            MapiRecipientCollection recColl = new MapiRecipientCollection();

            recColl.Add("*****@*****.**", "receiver", MapiRecipientType.MAPI_TO);
            MapiCalendar newCal = new MapiCalendar(
                "This is Location",
                "This is Summary",
                "This is recurrence test",
                startDate,
                startDate.AddHours(3),
                "*****@*****.**",
                recColl);

            newCal.Recurrence = recurrence;

            using (MemoryStream memory = new MemoryStream())
            {
                PersonalStorage pst            = PersonalStorage.Create(memory, FileFormatVersion.Unicode);
                FolderInfo      calendarFolder = pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);
                calendarFolder.AddMapiMessageItem(newCal);
            }
            //ExEnd: ModifyDeleteOccurrenceInRecurrence
        }
コード例 #3
0
        public static void Run()
        {
            string dataDir  = RunExamples.GetDataDir_Outlook();
            string fileName = dataDir + "Test Meeting.msg";

            MapiMessage  message  = MapiMessage.FromFile(fileName);
            MapiCalendar calendar = (MapiCalendar)message.ToMapiMessageItem();

            // ExStart:CreateMapiCalendarTimeZoneFromStandardTimezone
            MapiCalendarTimeZone timeZone = new MapiCalendarTimeZone(TimeZoneInfo.Local);

            // ExEnd:CreateMapiCalendarTimeZoneFromStandardTimezone

            calendar.StartDateTimeZone = timeZone;
            calendar.EndDateTimeZone   = timeZone;
        }
コード例 #4
0
        public static void Run()
        {
            //ExStart:CreatAndSaveCalendaritems
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create the appointment
            MapiCalendar calendar = new MapiCalendar(
                "LAKE ARGYLE WA 6743",
                "Appointment",
                "This is a very important meeting :)",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0));

            calendar.Save(dataDir + "CalendarItem_out.ics", AppointmentSaveFormat.Ics);
            //ExEnd:CreatAndSaveCalendaritems
        }
コード例 #5
0
        public static void Run()
        {
            //ExStart:CreatAndSaveCalendaritems
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create the appointment
            MapiCalendar calendar = new MapiCalendar(
                "LAKE ARGYLE WA 6743",
                "Appointment",
                "This is a very important meeting :)",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0));

            calendar.Save(dataDir + "CalendarItem_out.ics", AppointmentSaveFormat.Ics);
            //ExEnd:CreatAndSaveCalendaritems
        }
        public static void Run()
        {
            // ExStart:GenerateRecurrenceFromRecurrenceRule
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            DateTime startDate = new DateTime(2015, 7, 16);
            DateTime endDate = new DateTime(2015, 8, 1);
            MapiCalendar app1 = new MapiCalendar("test location", "test summary", "test description", startDate, endDate);

            app1.StartDate = startDate;
            app1.EndDate = endDate;

            string pattern = "DTSTART;TZID=Europe/London:20150831T080000\r\nDTEND;TZID=Europe/London:20150831T083000\r\nRRULE:FREQ=DAILY;INTERVAL=1;COUNT=7\r\nEXDATE:20150831T070000Z,20150904T070000Z";
            app1.Recurrence.RecurrencePattern = MapiCalendarRecurrencePatternFactory.FromString(pattern);
            // ExEnd:GenerateRecurrenceFromRecurrenceRule
        }         
コード例 #7
0
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:AddMapiCalendarToPST
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create the appointment
            MapiCalendar appointment = new MapiCalendar(
                "LAKE ARGYLE WA 6743",
                "Appointment",
                "This is a very important meeting :)",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0));

            // Create the meeting
            MapiRecipientCollection attendees = new MapiRecipientCollection();

            attendees.Add("*****@*****.**", "Renee A. Jones", MapiRecipientType.MAPI_TO);
            attendees.Add("*****@*****.**", "Szollosy Liza", MapiRecipientType.MAPI_TO);

            MapiCalendar meeting = new MapiCalendar(
                "Meeting Room 3 at Office Headquarters",
                "Meeting",
                "Please confirm your availability.",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0),
                "*****@*****.**",
                attendees
                );

            string path = dataDir + "AddMapiCalendarToPST_out.pst";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (PersonalStorage pst = PersonalStorage.Create(dataDir + "AddMapiCalendarToPST_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo calendarFolder = pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);
                calendarFolder.AddMapiMessageItem(appointment);
                calendarFolder.AddMapiMessageItem(meeting);
            }
            // ExEnd:AddMapiCalendarToPST
        }
        public static void Run()
        {
            // ExStart:GenerateRecurrenceFromRecurrenceRule
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            DateTime     startDate = new DateTime(2015, 7, 16);
            DateTime     endDate   = new DateTime(2015, 8, 1);
            MapiCalendar app1      = new MapiCalendar("test location", "test summary", "test description", startDate, endDate);

            app1.StartDate = startDate;
            app1.EndDate   = endDate;

            string pattern = "DTSTART;TZID=Europe/London:20150831T080000\r\nDTEND;TZID=Europe/London:20150831T083000\r\nRRULE:FREQ=DAILY;INTERVAL=1;COUNT=7\r\nEXDATE:20150831T070000Z,20150904T070000Z";

            app1.Recurrence.RecurrencePattern = MapiCalendarRecurrencePatternFactory.FromString(pattern);
            // ExEnd:GenerateRecurrenceFromRecurrenceRule
        }
コード例 #9
0
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:AddMapiCalendarToPST
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create the appointment
            MapiCalendar appointment = new MapiCalendar(
                "LAKE ARGYLE WA 6743",
                "Appointment",
                "This is a very important meeting :)",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0));

            // Create the meeting
            MapiRecipientCollection attendees = new MapiRecipientCollection();
            attendees.Add("*****@*****.**", "Renee A. Jones", MapiRecipientType.MAPI_TO);
            attendees.Add("*****@*****.**", "Szollosy Liza", MapiRecipientType.MAPI_TO);

            MapiCalendar meeting = new MapiCalendar(
                "Meeting Room 3 at Office Headquarters",
                "Meeting",
                "Please confirm your availability.",
                new DateTime(2012, 10, 2, 13, 0, 0),
                new DateTime(2012, 10, 2, 14, 0, 0),
                "*****@*****.**",
                attendees
                );

            string path = dataDir + "AddMapiCalendarToPST_out.pst";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (PersonalStorage pst = PersonalStorage.Create(dataDir + "AddMapiCalendarToPST_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo calendarFolder = pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);
                calendarFolder.AddMapiMessageItem(appointment);
                calendarFolder.AddMapiMessageItem(meeting);
            }
            // ExEnd:AddMapiCalendarToPST
        }
        // ExStart:GeneratingOccurrencesFromRecurrencePatterns
        public static void GetOccurences()
        {
            // The path to the File directory
            string        dataDir       = RunExamples.GetDataDir_KnowledgeBase();
            string        tempFileName  = dataDir + "Sample.pst";
            Appointment   appointment   = CreateAppointment();
            MailMessage   mailMessage   = CreateMessage();
            AlternateView alternateView = appointment.RequestApointment();

            mailMessage.AddAlternateView(alternateView);
            MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage);

            using (PersonalStorage pst = PersonalStorage.Create(tempFileName, FileFormatVersion.Unicode))
            {
                FolderInfo folder = pst.RootFolder.AddSubFolder("Calendar");
                folder.AddMessage(mapiMessage);
            }

            using (PersonalStorage pst = PersonalStorage.FromFile(tempFileName))
            {
                var folder = pst.RootFolder.GetSubFolder("Calendar");
                foreach (MessageInfo messageInfo in folder.GetContents())
                {
                    MapiMessage  message = pst.ExtractMessage(messageInfo);
                    MapiCalendar meeting = (MapiCalendar)message.ToMapiMessageItem();
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        meeting.Save(memoryStream);
                        string             s = StreamToString(memoryStream);
                        CalendarRecurrence recurrencePattern = new CalendarRecurrence(s);
                        DateCollection     occurrences       = recurrencePattern.GenerateOccurrences();
                        foreach (DateTime occurrence in occurrences)
                        {
                            Console.WriteLine("{0}", occurrence);
                        }
                    }
                }
            }

            File.Delete(tempFileName);
        }
コード例 #11
0
        public static void Run()
        {
            // ExStart:AddAudioReminderToCalendar
            // The path to the File directory.
            string      dataDir = RunExamples.GetDataDir_Outlook();
            Appointment app     = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "*****@*****.**", "*****@*****.**");

            MailMessage msg = new MailMessage();

            msg.AddAlternateView(app.RequestApointment());
            MapiMessage  mapi     = MapiMessage.FromMailMessage(msg);
            MapiCalendar calendar = (MapiCalendar)mapi.ToMapiMessageItem();

            // Set calendar properties
            calendar.ReminderSet           = true;
            calendar.ReminderDelta         = 58;//58 min before start of event
            calendar.ReminderFileParameter = dataDir + "Alarm01.wav";
            string savedFile = (dataDir + "calendarWithAudioReminder_out.ics");

            calendar.Save(savedFile, AppointmentSaveFormat.Ics);
            // ExEnd:AddAudioReminderToCalendar
        }