How to import or create an Outlook 2003 rule (.rwz) with VSTO 2005?
Question
I would like to automatically create an Outlook rule (move email containing something in subject to folder xyz) but dont know how to achieve this. Of course I can create the rule and export it to a .rwz file. This file can be imported manually, but how can I import it automatically?
Can I import a rule through my VSTO 2005 Outlook (2003) Addin? Or can I create the rule from within this addin?
Thanks in advance!
Solution
This cannot be done programmatically using the imported RWZ. You can create rules programmatically though. You can use CDO/RDO etc. or using the OOM directly inside an addin or macro. All slightly different degrees on things you can do.
Take a look at:
MSDN DEV Reference
http://msdn.microsoft.com/en-us/library/bb176397.aspx
How to: Create a Rule to Move Specific E-mails to a Folder
http://msdn.microsoft.com/en-us/library/bb206765.aspx
OTHER TIPS
A rule is just a way for the non-programmer to achieve what the programmer can already achieve with use of the Outlook Object model/CDO/.net/etc
I suggest you reevaluate the exact functionality you are trying to achieve and consider if it is really that essential to use a rule instead of a custom method (vsto, com addin, ext. automation of outlook, etc)