Re: Cuestom outlook rule using vba

  • Thread starter Thread starter Ken Slovak - [MVP - Outlook]
  • Start date Start date
Status
Not open for further replies.
K

Ken Slovak - [MVP - Outlook]

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.

"mherber2" <mherber2.3f756cd@outlookbanter.com> wrote in message

news:mherber2.3f756cd@outlookbanter.com...

> 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
 
thats not a problem can you assist me in writing the script?

' - [MVP - Outlook Wrote:
> ;295682']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.

> >

>

> "mherber2" mherber2.3f756cd@outlookbanter.com wrote in message
> news:mherber2.3f756cd@outlookbanter.com...-

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


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

"mherber2" <mherber2.3fb4b51@outlookbanter.com> wrote in message

news:mherber2.3fb4b51@outlookbanter.com...

> thats not a problem can you assist me in writing the script?
 
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

' - [MVP - Outlook Wrote:
> ;295859']Start coding it and post any problems or questions and someone
> will help.

> >

>

> "mherber2" mherber2.3fb4b51@outlookbanter.com wrote in message
> news:mherber2.3fb4b51@outlookbanter.com...-

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


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

"mherber2" <mherber2.3fc9cd5@outlookbanter.com> wrote in message

news:mherber2.3fc9cd5@outlookbanter.com...

> 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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
ughlook Open multiple contacts in NEW Outlook? Using Outlook 2
G Outlook translation feature is off Using Outlook 2
J Outlook 2010 does not let me put any account Using Outlook.com accounts in Outlook 3
P 3 of 5 PST files don't install from d:\outlook but only from D:\ Using Outlook 7
HarvMan January Windows 10 preview update force installs new Outlook Using Outlook 1
L Outlook 2010 - new installation on Windows 11 - aplzod32.dll is not a valid Add-in Using Outlook 10
J Outlook troubleshooting/logging - option grayed out Using Outlook 2
B Arrows missing from Outlook emails vertical scrollbar Using Outlook 0
G Outlook 2021 (New) doesn't respect default browser Using Outlook 8
B Outlook or iPhone turning tabs into spaces in Outlook Notes Using Outlook 1
P newly installed Office 365 includes OLD Outlook Using Outlook 6
R Outlook ribbon menu default? Using Outlook 7
H Spam email in Gmail not visible in Outlook Using Outlook 3
J How to transfer Win 10 Outlook to new Windows 11 pc? Using Outlook 11
J Renegade spam URL line displayed in old local Outlook 365 email title Using Outlook 3
G Reduce whitespace in Outlook desktop Contact Cards display Using Outlook 3
C Outlook classic via 365 Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
S Repair Outlook Using Outlook 8
V Outlook Form ListBox is not editable Outlook VBA and Custom Forms 2
F Outlook's contacts Using Outlook 1
D Outlook 2003 stopped dead Using Outlook 2
G Cannot receive emails from gmail account in Outlook 365 Using Outlook 1
E "Cannot display the folder. MS Outlook cannot access the specified file location" Using Outlook 8
P Outlook 2016 Working Offline Using Outlook 2
Rupert Dragwater Cannot reestablish gmail (email address) account in Outlook 365 Using Outlook 11
O Outlook 365 synchronisieren Exchange Server Administration 1
kburrows Outlook Classic - JPG files are corrupted when opened or saved Using Outlook 3
F Sync Outlook Calendar Using Outlook 0
G Change default font size in sticky notes - Outlook Desktop 2021 Using Outlook 2
C VBA in "New Outlook?" Using Outlook 0
D New Outlook with Business Basic Plans Using Outlook 0
D Outlook 2021 not working with Outlook 2003 installed Using Outlook 5
D Outlook 2003 stopped working - get they dialog box asking for username & Password Using Outlook 2
T Outlook 2021 hangs in close on taskbar occasionally Using Outlook 1
M Duplicate removal feature in Outlook 2021 is faulty Using Outlook 2
D.Moore Outlook COM addins source folder Using Outlook 12
P Removing Outlook 365 Account from Send/Receive Using Outlook 3
kburrows Outlook Automatically Merging Contacts Using Outlook 2
A Outlook 2016 Outlook 2016 vs. New Outlook Using Outlook 4
D Outlook Desktop App Email Software Using Outlook 0
efire9207 VBA Outlook Contacts Outlook VBA and Custom Forms 6
M Outlook not logging in to server Using Outlook 0
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 3
R Outlook 2021 change view Using Outlook 2
K Outlook font corrupted in some point sizes, resets on close/open Using Outlook 2
J Is the Windows Outlook Tasks module really going to be gone? Using Outlook 6
F Outlook 2010 and Hotmail Using Outlook 1
A Outlook 2021 needs 'enter' for people search Using Outlook 2
HarvMan Outlook 365 Inbox Font Using Outlook 8

Similar threads

Back
Top