?
Solved

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

Posted on 2010-01-10
3
Medium Priority
?
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

752 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