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

Cuestom outlook rule using vba



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 5th 09, 05:01 PM
mherber2 mherber2 is offline
Junior Member
 
First recorded activity at Outlookbanter: Mar 2009
Posts: 4
Default Cuestom outlook rule using vba

Hello all,

Im needing to create some custom rules to orginize my email for me.

I need to write a rule so that an email containning an specific word in the subject, sent to a person in a specific address book, or from a person in a specific address book moved to a specific folder.

I know i have to use vba because the wiz wont allow for an or it will only use and. Can any one please help me with this?
Ads
  #2  
Old March 6th 09, 03:13 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Cuestom outlook rule using vba

What version of Outlook? If this is Outlook 2007 you can use the new Rules
collection, if not then you must have a rule that calls into a VBA macro
formatted in a specific way.

See http://www.outlookcode.com/article.aspx?id=62 and look for the run a
script rule.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

Hello all,

Im needing to create some custom rules to orginize my email for me.

I need to write a rule so that an email containning an specific word in
the subject, sent to a person in a specific address book, or from a
person in a specific address book moved to a specific folder.

I know i have to use vba because the wiz wont allow for an or it will
only use and. Can any one please help me with this?




--
mherber2


  #3  
Old March 6th 09, 04:23 PM
mherber2 mherber2 is offline
Junior Member
 
First recorded activity at Outlookbanter: Mar 2009
Posts: 4
Default

i am using 2007 however there is not a built in rule to sort when a message is sent to someone in a specified address book

Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
What version of Outlook? If this is Outlook 2007 you can use the new Rules
collection, if not then you must have a rule that calls into a VBA macro
formatted in a specific way.

See http://www.outlookcode.com/article.aspx?id=62 and look for the run a
script rule.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

Hello all,

Im needing to create some custom rules to orginize my email for me.

I need to write a rule so that an email containning an specific word in
the subject, sent to a person in a specific address book, or from a
person in a specific address book moved to a specific folder.

I know i have to use vba because the wiz wont allow for an or it will
only use and. Can any one please help me with this?




--
mherber2
  #4  
Old March 9th 09, 02:38 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Cuestom outlook rule using vba

It looks like there aren't any conditions that meet what you want in the
Rules collection, so a rule that runs a script is your best bet.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

i am using 2007 however there is not a built in rule to sort when a
message is sent to someone in a specified address book


  #5  
Old March 9th 09, 04:45 PM
mherber2 mherber2 is offline
Junior Member
 
First recorded activity at Outlookbanter: Mar 2009
Posts: 4
Default

thats not a problem can you assist me in writing the script?

Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
It looks like there aren't any conditions that meet what you want in the
Rules collection, so a rule that runs a script is your best bet.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

i am using 2007 however there is not a built in rule to sort when a
message is sent to someone in a specified address book
  #6  
Old March 10th 09, 01:28 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Cuestom outlook rule using vba

Start coding it and post any problems or questions and someone will help.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

thats not a problem can you assist me in writing the script?


  #7  
Old March 10th 09, 04:52 PM
mherber2 mherber2 is offline
Junior Member
 
First recorded activity at Outlookbanter: Mar 2009
Posts: 4
Default

i have experiance in vba for excell and power point but i have no clue where to begin here. i've been working on coding it but cannt get anywhere

Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
Start coding it and post any problems or questions and someone will help.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

thats not a problem can you assist me in writing the script?
  #8  
Old March 11th 09, 01:54 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Cuestom outlook rule using vba

Well, the rule calling the macro "script" is passed a Mailitem object for
the item. To check for Subject containing a specific word:

Sub myRuleCode(Item As Outlook.MailItem)
If InStr(1, Item.Subject, "foobar", vbTextCompare) 0 Then
' it has the subject word "foobar" there

To check for the recipient being in a specific AddressBook you'd need to get
the Item.Recipients collection and iterate, checking each Recipient for
their email address and seeing if the Recipient.Type = olTo (if you only
want to check the To recipient or recipients).

The AddressBook would be retrieved from the AddressLists collection as an
AddressList object. You'd get its AddressEntries collection and iterate that
looking for an AddressEntry where the Address property was equal to the
Recipient.Address.

To check for the sender being in the AddressEntries collection you'd use the
Item.SenderEmailAddress property and compare that to each
AddressEntry.Address value in that AddressBook.

If you know the name of the AddressBook you want to work with you'd get it
like this:

Dim oList As Outlook.AddressList
Set oList =
Application.GetNameSpace("MAPI").AddressLists.Item ("myAddressList")

That should get you going.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mherber2" wrote in message
...

i have experiance in vba for excell and power point but i have no clue
where to begin here. i've been working on coding it but cannt get
anywhere


 




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
How to get outlook rule Ashish Add-ins for Outlook 1 February 21st 09 09:47 PM
Outlook rule Stefan Outlook - General Queries 1 December 4th 08 01:16 PM
outlook rule [email protected] Outlook - General Queries 2 May 2nd 07 01:52 PM
Outlook Rule JoeCL Outlook - Installation 1 November 21st 06 08:50 PM
How to setup a rule to forward rule in Outlook (xp or 2003) to forward emails from a certain domain when app isnt running? KingCronos Outlook - General Queries 7 November 15th 06 11:22 AM


All times are GMT +1. The time now is 02:43 PM.


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.