The question was posed on the newsgroup: how do I delete emails (over POP or IMAP) on a remote mail server through PowerShell?
Here’s an example of one way to do it – through the use of the get-imap, set-imap, and get-pop cmdlets that are included in NetCmdlets.
There you are. First I have defined a function to take a sender address and parse out the email address (in case the sender address includes a friendly name – if you’re not familiar with this, its not really important anyway). Then I check to make sure we have a server to connect to, and depending on whether or not we’re using POP or IMAP, I connect to the server and get a list of waiting messages using get-pop or get-imap. Finally, I loop through each message, and if the sender address matches the one I’m looking for, I output and then delete the message.