How do I run a rule by using a toolbar icon?

D

DLGolfs

I have Outlook 2007 and have a rule set up to delte spam by detecting certain
words in the spam.
Here is what someone gave me but it does not work:

Sub RunRuleDeleteSpam()
Dim oNS As Outlook.NameSpace
Dim oStore As Outlook.Store
Dim colRules As Outlook.Rules
Dim oRule as Outlook.Rule

Set oNS = Application.GetNameSpace("MAPI")
Set oStore = oNS.DefaultStore
Set colRules = oStore.Rules
Set oRule = colRules.Item("Delete Spam")
oRule.Execute
End Sub
If I run it it highlights the set oRule line and stops, I guess. I know
nothing about programming, I'll admit, but am not ignorant on computer
processes. I thought if I could make a macro to run a rule then I could put
the macro in a toolbar icon and just click on it instead of having to go
through a series of clicks.
What do you think? Is the formula wrong or what?
 
D

DLGolfs

No error just highlights the the line
Yes, the rul Delete Spam does exisit, I can run it manually all the time.

I tried to export the rules and put the file here but it did not work.
I have the rule name Delete Spam
 
D

DLGolfs

No error just highlights the line as I stated below. That is it.
Yes, the rule Delete Spam does exisit, I can run it manually all the time.

I tried to export the rules and put the file here but it did not work.
I have the rule name Delete Spam
 
M

Michael Bauer [MVP - Outlook]

if you modify the code to this:

On Error Resume Next
Set oRule = colRules.Item("Delete Spam")
MsgBox Err.Description

what does the prompt tell you?

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
<http://www.vboffice.net/product.html?lang=en>


Am Sat, 20 Mar 2010 03:23:01 -0700 schrieb DLGolfs:
 

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