Aspose.Email.Examples.CSharp.Email.Outlook.DeleteBulkItemsFromPSTFile.Run C# (CSharp) Метод

Run() публичный статический Метод

public static Run ( ) : void
Результат void
        public static void Run()
        {
            // ExStart:DeleteBulkItemsFromPSTFile
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook() + @"Sub.pst";
            using (PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir))
            {
                // Get Inbox SubFolder from Outlook file
                FolderInfo inbox = personalStorage.RootFolder.GetSubFolder("Inbox");

                // Create instance of PersonalStorageQueryBuilder
                PersonalStorageQueryBuilder queryBuilder = new PersonalStorageQueryBuilder();

                queryBuilder.From.Contains("[email protected]");
                MessageInfoCollection messages = inbox.GetContents(queryBuilder.GetQuery());
                IList<string> deleteList = new List<string>();
                foreach (MessageInfo messageInfo in messages)
                {
                    deleteList.Add(messageInfo.EntryIdString);
                }

                // delete messages having From = "[email protected]"
                inbox.DeleteChildItems(deleteList);
            }
            // ExEnd:DeleteBulkItemsFromPSTFile
        }
    }
DeleteBulkItemsFromPSTFile