Reputation: 598
there must be a way of doing this using the MAPI.
I have
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder($olFolderInbox);
$inbox.Folders `
| ? name -eq Subfolder1 `
| % Items
There must be a way of deleting the contents of this subfolder folder after the full script runs, so the subfolder is clear for the next time the script runs to process only the items as they come in new. (so as not to have processed files reprocessing). Any ideas?
Upvotes: 1
Views: 2567
Reputation: 8889
Simply Use the Delete Method:
$ns = $outlook.GetNameSpace("MAPI");
$inbox = $ns.GetDefaultFolder('olFolderInbox')
$SubFolders = $inbox.Folders
To Delete all the Subfolders with the contents:
$SubFolders | % {$_.Delete()}
To Delete only The Contents
foreach ($SubFolder in $SubFolders)
{
While ($Subfolder.Items.Count -ne 0)
{
$SubFolder.Items | % {$_.delete()}
}
}
While Loop
, like in the exampleUpvotes: 1