See "Windows Mail (formerly Outlook Express)" at:
http://msdn.microsoft.com/en-us/library/ms709546(VS.85).aspx
It documents an API that could be used to do what you are trying to do.
Unfortunately it cannot be used from a macro. It is difficult to even use it
from a .Net environment such as C#. Microsoft has not provided a more
convenient API obviously because they don't want to do anything more with OE
and WinMail.
Also see "Simple MAPI" at:
http://msdn.microsoft.com/en-us/library/dd296734(VS.85).aspx
Simple MAPI can also be used with OE and WinMail, but it can only access the
InBox folder; it cannot access any messages in any other folder. Note that
it says "Deprecated" many times because they don't want to do anything more
with OE and WinMail.
See the "System.Net.Mail Namespace" API at:
http://msdn.microsoft.com/en-us/library/system.net.mail.aspx
You can use that in any program that supports .Net, but it does not do
anything with incoming mail nor does it do anything with messages already
received.
Also see "Messaging and Collaboration", which lists a few other
possibilities. I am not familiar with anything you can use in a script,
except maybe CDO. There are actually multiple versions of CDO and the are
the same by name only; they are not all the same. There is at least one
version of CDO that can do what you need to do but it is likely not
available without installing Outlook or other purchased email software.
Since WinMail stores messages in files, you might be able to access the
messages external from WinMail, but that is not likely to work unless you
can write something that reads the messages to get all the properties you
need. If you were able to do that, then you could delete the relevant files.
That would however likely corrupt the message store but hopefully that can
be re-created somehow. Other experts here could help with that.
The WinMail message store (where details such as subject, sender, date and
size are stored) reportedly uses a "Jet" Red or Blue database, which is the
same as or similar to the Access databases. I can't find documentation that
clarifies that however.