PDA

View Full Version : Is there a way, to delete sent mail from a mailbox, if the mail got delivered?



antlz
01-08-2014, 02:58 AM
Hi guys, I'm new to this board, because this is the first time I have to work with outlook macros.
And I am relatively new to outlook-vba, but I've figured a few things out, by browsing different forums, and msdn.

However, there is one thing I haven't found anywhere.

Is it possible, when a message is sent out with either: requesting a delivery reciept or a read reciept, and you recieve these notification, to delete the subjected mail?

Each mail has a unique id in their subject, if it helps.

Thanks in advance,
Z

westconn1
01-10-2014, 05:31 AM
you can try like

Set myfolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)
Set g = myfolder.Items.Restrict("[subject] > 'test'") ' change this to match your subject
Do While g.Count > 0
g.Remove 1
Looptest carefully, i am not sure if read receipts are linked to the sent mail, if they are it would probably be better to use that than the subject