Exemple #1
0
            public void UpdatePstFileInfo_WhenLastSuccessfulBackupChangeToNull()
            {
                // Arrange
                SUT sut = new SUT(_dbPath);

                sut.Connect();
                string  clientId          = Guid.NewGuid().ToString();
                PstFile pstFileToRegister = new PstFile()
                {
                    LocalPath     = @"C:\Pst Files\Courtel\Archive1.pst",
                    IsSetToBackup = true,
                    Size          = 57_345_786
                };

                // Act
                Assert.IsFalse(sut.IsPstFileExists(clientId, pstFileToRegister.LocalPath));
                sut.RegisterPstFile(clientId, pstFileToRegister);

                pstFileToRegister.LastSuccessfulBackup = DateTime.UtcNow;
                sut.RegisterPstFile(clientId, pstFileToRegister);
                Assert.IsNotNull(sut.GetPstFile(clientId, pstFileToRegister.LocalPath).LastSuccessfulBackup);
                pstFileToRegister.LastSuccessfulBackup = null;
                sut.RegisterPstFile(clientId, pstFileToRegister);
                PstFile updatedPstFile = sut.GetPstFile(clientId, pstFileToRegister.LocalPath);

                // Assert
                Assert.IsNull(updatedPstFile.LastSuccessfulBackup);
            }
Exemple #2
0
            public void RegisterRightInformationsFromPstFile_WhenPstFileDoNotExists()
            {
                // Arrange
                SUT sut = new SUT(_dbPath);

                sut.Connect();
                string  clientId          = Guid.NewGuid().ToString();
                PstFile pstFileToRegister = new PstFile()
                {
                    LocalPath            = @"C:\Pst Files\Courtel\Archive1.pst",
                    IsSetToBackup        = true,
                    Size                 = 57_345_786,
                    LastSuccessfulBackup = null
                };

                // Act
                Assert.IsFalse(sut.IsPstFileExists(clientId, pstFileToRegister.LocalPath));
                sut.RegisterPstFile(clientId, pstFileToRegister);
                PstFile insertedPstFile = sut.GetPstFile(clientId, pstFileToRegister.LocalPath);

                // Assert
                Assert.AreEqual(pstFileToRegister.LocalPath, insertedPstFile.LocalPath, true);
                Assert.AreEqual(pstFileToRegister.IsSetToBackup, insertedPstFile.IsSetToBackup);
                Assert.AreEqual(pstFileToRegister.Size, insertedPstFile.Size);
                Assert.AreEqual(pstFileToRegister.LastSuccessfulBackup, insertedPstFile.LastSuccessfulBackup);
            }
Exemple #3
0
        static void Main(string[] args)
        {
            PstFile file = new PstFile("c:\\testfolder\\Outlook.pst");

            using (file)
            {
                Folder inbox = file.MailboxRoot.GetFolder("Inbox");

                if (inbox != null)
                {
                    ItemCollection items = inbox.GetItems();

                    for (int m = 0; m < items.Count; m++)
                    {
                        if (items[m] is Message)
                        {
                            Message message = (Message)items[m];

                            Console.WriteLine("Id: " + message.Id);
                            Console.WriteLine("Subject: " + message.Subject);
                            Console.WriteLine("DisplayTo: " + message.DisplayTo);
                            Console.WriteLine("DisplayCc: " + message.DisplayCc);
                            Console.WriteLine("SenderName: " + message.SenderName);
                            Console.WriteLine("SenderEmailAddress: " + message.SenderEmailAddress);
                            Console.WriteLine("----------------------------------------------------------------");
                        }
                    }
                }
            }

            Console.WriteLine("Press ENTER to exit.");
            Console.Read();
        }
Exemple #4
0
 /// <summary>
 /// Sets the local WorkingPst instance to pstFilepath.
 /// If another pst is opened then the previous pst is closed
 /// </summary>
 private void SetWorkingPst(string pstFilePath)
 {
     if (string.Compare(pstFilePath, WorkingPstFilePath ?? string.Empty, true) != 0)
     {
         CloseWorkingPst();
         WorkingPst         = new PstFile(pstFilePath);
         WorkingPstFilePath = pstFilePath;
     }
 }
Exemple #5
0
 private void ParseMailBoxFolders()
 {
     PstFile pstFileLoad = new PstFile(PST_FILE_PATH);
     using (pstFileLoad)
     {
         FolderCollection mailboxFolders = pstFileLoad.MailboxRoot.GetFolders();
         foreach (Folder mailboxFolder in mailboxFolders)
         {
             if (mailboxFolder.HasSubFolders)
             {
                 ParseMailBoxSubFolders(mailboxFolder);
             }
             LoadMailsFromFolders(mailboxFolder);
         }
     }
 }
 /// <summary>
 /// Sets the local WorkingPst instance to pstFilepath. 
 /// If another pst is opened then the previous pst is closed
 /// </summary>
 private void SetWorkingPst(string pstFilePath)
 {
     if (string.Compare(pstFilePath, WorkingPstFilePath ?? string.Empty, true) != 0)
     {
         CloseWorkingPst();
         WorkingPst = new PstFile(pstFilePath);
         WorkingPstFilePath = pstFilePath;
     }
 }
Exemple #7
0
 private void OpenFile(string path)
 {
     _currentFile = new PstFile(File.OpenRead(path));
     PopulateFolders();
 }