Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / June 2006

Tip: Looking for answers? Try searching our database.

Possible to create rule that uses keywords located in a text file?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CodeKid - 26 Jun 2006 18:21 GMT
In Outlook 2003, rules based on keywords require that each keyword be entered
one at a time. I need to execute a rule based on a lengthly list (not a spam
filter) of words that will need to be changed often. I'd like to do this by
maintaining a text file of the words and have a VBA script (or rule)
reference that file.

Is this possible?

I've written code for Excel but never Outlook. Any guidance/code you can
offer would be greatly appreciated.

-CodeKid
Michael Bauer - 27 Jun 2006 05:31 GMT
Am Mon, 26 Jun 2006 10:21:02 -0700 schrieb CodeKid:

In OL 2007 (beta available) you could do that, in 03 you can´t.

Signature

Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
 -- www.VBOffice.net --

> In Outlook 2003, rules based on keywords require that each keyword be entered
> one at a time. I need to execute a rule based on a lengthly list (not a spam
[quoted text clipped - 8 lines]
>
> -CodeKid
Sue Mosher [MVP-Outlook] - 27 Jun 2006 22:31 GMT
Another approach would be to use a run a script rule action (see example below) to use information read in from a file and process the message with that data. You'd want to read in the file data just once, when Outlook starts.

However, given that there are free antispam tools out there, you might be better off using one of them to do the processing. No doubt it will have optimizations that OUtlook VBA code doesn't.

Here's what a basic "run a script" rule looks like:

Sub RunAScriptRuleRoutine(MyMail As MailItem)
   Dim strID As String
   Dim olNS As Outlook.NameSpace
   Dim msg As Outlook.MailItem
   
   strID = MyMail.EntryID
   Set olNS = Application.GetNamespace("MAPI")
   Set msg = olNS.GetItemFromID(strID)
   ' do stuff with msg, e.g.
   MsgBox msg.SUbject    
   
   Set msg = Nothing
   Set olNS = Nothing
End Sub

See http://www.outlookcode.com/d/code/zaphtml.htm#ol2002 for another example.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

> In Outlook 2003, rules based on keywords require that each keyword be entered
> one at a time. I need to execute a rule based on a lengthly list (not a spam
[quoted text clipped - 8 lines]
>
> -CodeKid
CodeKid - 28 Jun 2006 14:54 GMT
Susan,

Thanks very much for the info. One question remains though -- I'm not
familiar with any of the objects in Outlook and the lack of a macro recorder
makes it difficult to figure that out.

In the example that you gave is "msg.Subject" the text if the subject line
from the message?

If so, I think I can have the script reference a text file with the words I
want to search for just by using InStr and a loop.

Would the script-based rule check the text file every time a new message
comes in or would the contents of the file be loaded only when Outlook starts
up?

Thanks again for all of your assistance.

> Another approach would be to use a run a script rule action (see example below) to use information read in from a file and process the message with that data. You'd want to read in the file data just once, when Outlook starts.
>
[quoted text clipped - 31 lines]
> >
> > -CodeKid
Sue Mosher [MVP-Outlook] - 28 Jun 2006 15:00 GMT
It's Sue,  not Susan.

>  the lack of a macro recorder
> makes it difficult to figure that out.

When in doubt, check the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch from <All Libraries> to Outlook to browse all Outlook objects and their properties, methods, and events. Select any object or member, then press F1 to see its Help topic. Also, there are many, many examples of Outlook code here and on the web. And please ask questions about any code you don't understand.

> In the example that you gave is "msg.Subject" the text if the subject line
> from the message?

Exactly. msg is the object representing the message. Subject is the property corresponding to the subject.

> Would the script-based rule check the text file every time a new message
> comes in or would the contents of the file be loaded only when Outlook starts
> up?

I'd code it using the latter technique.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

> Susan,
>
[quoted text clipped - 36 lines]
>>
>> See http://www.outlookcode.com/d/code/zaphtml.htm#ol2002 for another example.

>>    
>> > In Outlook 2003, rules based on keywords require that each keyword be entered
[quoted text clipped - 9 lines]
>> >
>> > -CodeKid
CodeKid - 28 Jun 2006 19:12 GMT
VERY sorry about the name, Sue  :)

And thanks again for all of your help.

> It's Sue,  not Susan.
>
[quoted text clipped - 68 lines]
> >> >
> >> > -CodeKid
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.