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



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.

--
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

"CodeKid" <CodeKid@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:40E79E86-4A1C-4863-BE9B-57E671117B13@xxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: Execute Macro from Rule
    ... A "run a script" rule action actually uses not an external script but a VBA procedure with a MailItem or MeetingItem as its parameter. ... Set msg = olNS.GetItemFromID ... Sue Mosher, Outlook MVP ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Script help - retain forwarded email body & location of script
    ... Author of Microsoft Outlook 2007 Programming: ... I am not sure I've saved the script in an appropriate location. ... Dim olNS As Outlook.NameSpace ... Set msg = olNS.GetItemFromID ...
    (microsoft.public.outlook.program_vba)
  • Re: Automatic action upon reception of a message
    ... Consider writing a VBA procedure for use with a "run a script" rule action. ... Such a procedure has the incoming MailItem or MeetingItem as its parameter. ... Set olNS = Application.GetNamespace ... Set msg = olNS.GetItemFromID ...
    (microsoft.public.outlook.program_vba)
  • Re: Writing small file for each received Outlook 2003 email message
    ... SenderName shouldn't raise a prompt if the code is constructed properly. ... In a "run a script" rule procedure, that means getting the item with the Namespace.GetItemFromID method: ... Set olNS = Application.GetNamespace ... Set msg = olNS.GetItemFromID ...
    (microsoft.public.outlook.program_vba)
  • Re: rules to run macro
    ... Outlook 2000 SP-3, and "run a script" is not available. ... Set olNS = Application.GetNamespace ... Set msg = olNS.GetItemFromID ...
    (microsoft.public.outlook)