Aspose.Email.Examples.CSharp.Email.Outlook.SpecificCriterionSplitPST.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:SpecificCriterionSplitPST
            string dataDir = RunExamples.GetDataDir_Outlook();
            IList<MailQuery> criteria = new List<MailQuery>();
            PersonalStorageQueryBuilder pstQueryBuilder = new PersonalStorageQueryBuilder();
            pstQueryBuilder.SentDate.Since(new DateTime(2005, 04, 01));
            pstQueryBuilder.SentDate.Before(new DateTime(2005, 04, 07));
            criteria.Add(pstQueryBuilder.GetQuery());
            pstQueryBuilder = new PersonalStorageQueryBuilder();
            pstQueryBuilder.SentDate.Since(new DateTime(2005, 04, 07));
            pstQueryBuilder.SentDate.Before(new DateTime(2005, 04, 13));
            criteria.Add(pstQueryBuilder.GetQuery());

            if (Directory.GetFiles(dataDir + "pathToPst", "*.pst").Length == 0)
            {
                
            }
            else
            {
                string[] files = Directory.GetFiles(dataDir + "pathToPst");

                foreach (string file in files)
                {
                    if(file.Contains(".pst"))
                    File.Delete(file);
                }
            }

            using (PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir + "PersonalStorage_New.pst"))
            {
                personalStorage.SplitInto(criteria, dataDir + "pathToPst");
            }
            // ExEnd:SpecificCriterionSplitPST
        }
    }
SpecificCriterionSplitPST