How to create hidden rule in outlook 2007

N

nitwalke

Hi all,

I am developing outlook plug-in for outlook 2007. I have create
programmatic- ally rule and it works fine.This rule can see in 'Rule
and Alert' window.Can user hide this rule? or how can create hidden rul
and set it's execution order first?

Thanks in advance
 
K

Ken Slovak - [MVP - Outlook]

If you use the rules object model the resulting rule cannot be hidden, it
will show up in the rules wizard. You would need to code the equivalent of
the rule as macro code or a COM addin and replace the rule completely.
 
N

nitwalke

Thanks for reply,

How can we use COM addin to replace the rule?Can I get some example? o
more explanation.
I have created COM addin and used rule object and rule can seen in rul
wizard.


Outlook.MAPIFolder inbox
this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder targetfolder = inbox.Folders["Test"];

rules = this.Application.Session.DefaultStore.GetRules();
rule = rules.Create("TestRule"
Microsoft.Office.Interop.Outlook.OlRuleType.olRuleReceive);

Outlook.TextRuleCondition sub = rule.Conditions.Subject;
sub.Enabled = true;
sub.Text = new string[] {"Test Subject"};

movecopy = rule.Actions.MoveToFolder;
movecopy.Enabled = true;
movecopy.Folder = targetfolder;

rule.Execute(true, inbox, false
Outlook.OlRuleExecuteOption.olRuleExecuteUnreadMessages);

How COM addin can use to create hidden rule?

'Ken Slovak - [MVP - Outlook said:
;109892']If you use the rules object model the resulting rule cannot b
hidden, it
will show up in the rules wizard. You would need to code the equivalen
of
the rule as macro code or a COM addin and replace the rule completely.




message
 
K

Ken Slovak - [MVP - Outlook]

As I said, you cannot use an addin to create a hidden rule, there is no such
thing.

You would use code in an addin to replicate what your rule does, under the
same conditions. Since a rule runs when items are added to the Inbox, you
need an ItemAdd() handler for Inbox.Items or a handler for NewMailEx(). Then
you would test the incoming item for the same conditions the rule would test
for, and take the same action the rule would take. In this case you would
test the subject for certain text and move the item if the test was true.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top