A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 26th 06, 06:21 PM posted to microsoft.public.outlook.program_vba
CodeKid
external usenet poster
 
Posts: 4
Default Possible to create rule that uses keywords located in a text file?

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


  #2  
Old June 27th 06, 05:31 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Possible to create rule that uses keywords located in a text file?

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.

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

  #3  
Old June 27th 06, 10:31 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default 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" wrote in message ...
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


  #4  
Old June 28th 06, 02:54 PM posted to microsoft.public.outlook.program_vba
CodeKid
external usenet poster
 
Posts: 4
Default Possible to create rule that uses keywords located in a text f

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.




"Sue Mosher [MVP-Outlook]" wrote:

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" wrote in message ...
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



  #5  
Old June 28th 06, 03:00 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Possible to create rule that uses keywords located in a text f

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.

--
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" wrote in message ...
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.




"Sue Mosher [MVP-Outlook]" wrote:

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.



"CodeKid" wrote in message ...
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



  #6  
Old June 28th 06, 07:12 PM posted to microsoft.public.outlook.program_vba
CodeKid
external usenet poster
 
Posts: 4
Default Possible to create rule that uses keywords located in a text f

VERY sorry about the name, Sue

And thanks again for all of your help.



"Sue Mosher [MVP-Outlook]" wrote:

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.

--
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" wrote in message ...
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.




"Sue Mosher [MVP-Outlook]" wrote:

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.



"CodeKid" wrote in message ...
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




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a new contact list from a text file Janet W Outlook - Using Contacts 1 June 12th 06 03:43 PM
deliver email to a pst file located in My Documents folder tb Outlook - Installation 3 April 23rd 06 12:23 AM
Create rule by script Louis Outlook and VBA 3 March 15th 06 04:49 PM
Create a re-running rule JDR Outlook - General Queries 2 February 15th 06 09:17 PM
How to create a distribution list based on contents of a text file yjwonder Outlook - Using Contacts 1 January 9th 06 10:12 PM


All times are GMT +1. The time now is 06:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2025 Outlook Banter.
The comments are property of their posters.