Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Executing outlook rule in the junk e-mail folder with vba

Posted on 2010-01-10
3
Medium Priority
?
737 Views
Last Modified: 2013-11-25
I have vba code that executes outllok rules in the default inbox folder. I would like to use the same code to execute the rule in the Junk E-mail folder.  Here is my code for the inbox folder. I know that I have to referebce the junk e-mail folder some how but I do not know how.

Dim objectstore As Outlook.Store
Dim colrules As Outlook.Rules
Dim objrule As Outlook.Rule, objcal As Outlook.Folder
Dim intcount As Integer
Dim strrrulelist As String
On Error Resume Next

Set objstore = Application.Session.DefaultStore
Set colrules = objstore.GetRules
colrules.Item("myrule").Execute showprogress:=True, Folder:=???????
0
Comment
Question by:datameans
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 200 total points
ID: 26310538
Hi, datameans.

Here's how to run a rule against a specific folder.


Dim objectstore As Outlook.Store
Dim colrules As Outlook.Rules
Dim objrule As Outlook.Rule, objcal As Outlook.Folder
Dim intcount As Integer
Dim strrrulelist As String
On Error Resume Next

Set objcal = Session.GetDefaultFolder(olFolderJunk)
Set objstore = Application.Session.DefaultStore
Set colrules = objstore.GetRules
colrules.Item("myrule").Execute showprogress:=True, Folder:=objcal

Open in new window

0
 

Author Closing Comment

by:datameans
ID: 31675182
Good job
0
 
LVL 76

Expert Comment

by:David Lee
ID: 26344529
Thanks.  Glad I could help.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question