I have some code to keep my inbox clean.
Process:
- Manually mall mails from outbox to inbox. Now I have all mails to be archived in inbox.
- Run code.
When I had a pop3/*pst-files setup, I used Outlook rules and had some code to run all rules on inbox.
When changing setup to Exchange, problems with rules arrived.
Suddenly I had many duplicates of rules, Outlook could not sync to server etc.
Now I have a simple and effective concept where a rule looks like this:
@somedomain.dk|XYZ
The rule says: Move all emails to/from sender on @somedomain.dk to Exchange-folder XYZ.
I select mails to be moved with this line:
Set mItems = inbox.Items.Restrict(strQry)
iNo = mItems.count
The query (it works):
@SQL="urn:schemas:httpmail:displayto" like '%somedomain.dk%' OR
"urn:schemas:httpmail:fromemail" like '%somedomain.dk%'
In the inbox I have 7 mails: Received 4 from and sent 3 to this domain. When running the code 5 mails are collected. Of the 3 emails I have sent, 1 is created by me and 2 are replies. Using Outlook Spy I find that MailItem.To holds both name and email address in the mail I have created, but only name when replying.
How can I change the query so I get the email address? I have looked around in Outlook Spy but got lost.