コード例 #1
0
        public static void Run()
        {
            // ExStart:AccessContactInformation
            // Load the Outlook file
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook PST file
            PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir + "SampleContacts.pst");
            // Get the Contacts folder
            FolderInfo folderInfo = personalStorage.RootFolder.GetSubFolder("Contacts");
            // Loop through all the contacts in this folder
            MessageInfoCollection messageInfoCollection = folderInfo.GetContents();

            foreach (MessageInfo messageInfo in messageInfoCollection)
            {
                // Get the contact information
                MapiMessage mapi = personalStorage.ExtractMessage(messageInfo);

                MapiContact contact = (MapiContact)mapi.ToMapiMessageItem();

                // Display some contents on screen
                Console.WriteLine("Name: " + contact.NameInfo.DisplayName);
                // Save to disk in MSG format
                if (contact.NameInfo.DisplayName != null)
                {
                    MapiMessage message = personalStorage.ExtractMessage(messageInfo);
                    // Get rid of illegal characters that cannot be used as a file name
                    string messageName = message.Subject.Replace(":", " ").Replace("\\", " ").Replace("?", " ").Replace("/", " ");
                    message.Save(dataDir + "Contacts\\" + messageName + "_out.msg");
                }
            }
            // ExEnd:AccessContactInformation
        }
コード例 #2
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:LoadingContactFromMSG
            MapiMessage msg         = MapiMessage.FromFile(dataDir + "Contact.msg");
            MapiContact mapiContact = (MapiContact)msg.ToMapiMessageItem();
            // ExEnd:LoadingContactFromMSG
        }
コード例 #3
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:ReadingMapiTask
            MapiMessage msg   = MapiMessage.FromFile(dataDir + "MapiTask.msg");
            MapiTask    task2 = (MapiTask)msg.ToMapiMessageItem();
            // ExEnd:ReadingMapiTask
        }
コード例 #4
0
 public static void Run()
 {
     // ExStart:ReadMapiNote
     // The path to the File directory.
     string      dataDir = RunExamples.GetDataDir_Outlook();
     MapiMessage note    = MapiMessage.FromFile(dataDir + "MapiNote.msg");
     MapiNote    note2   = (MapiNote)note.ToMapiMessageItem();
     // ExEnd:ReadMapiNote
 }
コード例 #5
0
        public static void Run()
        {
            // ExStart:AddMapiNoteToPST
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiMessage mess = MapiMessage.FromFile(dataDir + "Note.msg");

            // Create three Notes
            MapiNote note1 = (MapiNote)mess.ToMapiMessageItem();

            note1.Subject = "Yellow color note";
            note1.Body    = "This is a yellow color note";

            MapiNote note2 = (MapiNote)mess.ToMapiMessageItem();

            note2.Subject = "Pink color note";
            note2.Body    = "This is a pink color note";
            note2.Color   = NoteColor.Pink;

            MapiNote note3 = (MapiNote)mess.ToMapiMessageItem();

            note2.Subject = "Blue color note";
            note2.Body    = "This is a blue color note";
            note2.Color   = NoteColor.Blue;
            note3.Height  = 500;
            note3.Width   = 500;

            string path = dataDir + "AddMapiNoteToPST_out.pst";

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

            using (PersonalStorage personalStorage = PersonalStorage.Create(dataDir + "AddMapiNoteToPST_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo notesFolder = personalStorage.CreatePredefinedFolder("Notes", StandardIpmFolder.Notes);
                notesFolder.AddMapiMessageItem(note1);
                notesFolder.AddMapiMessageItem(note2);
                notesFolder.AddMapiMessageItem(note3);
            }
            // ExEnd:AddMapiNoteToPST
        }
コード例 #6
0
        public static void Run()
        {
            string dataDir  = RunExamples.GetDataDir_Outlook();
            string fileName = dataDir + "NewGroup.msg";

            // ExStart:ReadingDistributionListFromPST
            MapiMessage          message = MapiMessage.FromFile(fileName);
            MapiDistributionList dlist   = (MapiDistributionList)message.ToMapiMessageItem();
            // ExEnd:ReadingDistributionListFromPST
        }
コード例 #7
0
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:CreateNewMapiCalendarAndAddToCalendarSubfolder
            string      dataDir = RunExamples.GetDataDir_Outlook();
            MapiMessage message = MapiMessage.FromFile(dataDir + "Note.msg");

            // Note #1
            MapiNote note1 = (MapiNote)message.ToMapiMessageItem();

            note1.Subject = "Yellow color note";
            note1.Body    = "This is a yellow color note";

            // Note #2
            MapiNote note2 = (MapiNote)message.ToMapiMessageItem();

            note2.Subject = "Pink color note";
            note2.Body    = "This is a pink color note";
            note2.Color   = NoteColor.Pink;

            // Note #3
            MapiNote note3 = (MapiNote)message.ToMapiMessageItem();

            note2.Subject = "Blue color note";
            note2.Body    = "This is a blue color note";
            note2.Color   = NoteColor.Blue;
            note3.Height  = 500;
            note3.Width   = 500;

            if (File.Exists(dataDir + "SampleNote_out.pst"))
            {
                File.Delete(dataDir + "SampleNote_out.pst");
            }

            using (PersonalStorage pst = PersonalStorage.Create(dataDir + "SampleNote_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo notesFolder = pst.CreatePredefinedFolder("Notes", StandardIpmFolder.Notes);
                notesFolder.AddMapiMessageItem(note1);
                notesFolder.AddMapiMessageItem(note2);
                notesFolder.AddMapiMessageItem(note3);
            }
            // ExEnd:CreateNewMapiCalendarAndAddToCalendarSubfolder
        }
コード例 #8
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;
        }
        // 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);
        }
コード例 #10
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
        }