Re: Cuestom outlook rule using vba

  • Thread starter Ken Slovak - [MVP - Outlook]
  • 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
 
M

mherber2

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
 
K

Ken Slovak - [MVP - Outlook]

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

mherber2

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
 
K

Ken Slovak - [MVP - Outlook]

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.
Thread starter Similar threads Forum Replies Date
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 0
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 1
D Outlook 2010 Outlook in Windows 10 keeps asking for user name and password repeatedly Using Outlook 0
S Outlook mail adressing stops after first match in GAL Using Outlook 0
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
T Changing Sent Items location in Outlook 2019 Using Outlook 0
J How do I disable advertising in Outlook 2019? Using Outlook 5
S Outlook (2016 32bit; Gmail IMAP) - Save sent message to Outllook Folder Outlook VBA and Custom Forms 0
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
B Outlook Calendar not coming down from cloud Using Outlook 2
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
GregS Outlook 2016 Can I disable the Outlook Outbox? Using Outlook 2
P Outlook pst file is too huge with POP3. How to save more space? Using Outlook 4
D Outlook Contacts Notes Field Photos to Smartphone Using Outlook 0
Paula S. Outlook 2013 won't recognize new password Using Outlook 4
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
A Backup Email Accounts On OutLook For Mac 2016 (Microsoft 365 subscription version) Using Outlook 0
J Time Zone Issues - Outlook Calendar and Webcal Feed Using Outlook 8
J Are the underlined letters in Outlook Reminders window supposed to work? Using Outlook 0
M Office 2016 Outlook is forgetting passwords Using Outlook 14
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
W Outlook WAS facebook but there is no info for old accounts Using Outlook 0
E Can one still buy Outlook (or Office) 2016? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
E Outlook view grouping keeps changing Using Outlook 3
Wayne Outlook locks up when opening "Manage Rules & Alerts" Using Outlook 3
G Personal Settings within Outlook Using Outlook 2
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
H Outlook 2019 Certificate error Using Outlook 2
B Outlook 2013 erratically deleting original file that is attached Using Outlook 0
V Outlook Forms: Formatting a Label with 2 different styles Outlook VBA and Custom Forms 1
M Outlook 2016 Outlook randomly unhides from taskbar Using Outlook 12
X Using Outlook 2013 and Outlook 365 Using Outlook 1
V Date and/or time error in Outlook Form Outlook VBA and Custom Forms 0
D Sending email from Office 365 alias in Outlook Using Outlook 3
B Spam folder not showing in Outlook Using Outlook 5
ThinkToday Calculate reply time of outlook mail Using Outlook 1
M Microsoft 365 Outlook keeps requesting password on Local Account Using Outlook 1
I Outlook 365 - import/attach PST file that used POP3 Using Outlook.com accounts in Outlook 0
e_a_g_l_e_p_i I think it may be time to upgrade from Outlook 2010 Using Outlook 3
K Outlook 2016 Outlook, Chrome, and Clio Using Outlook 5
O Outlook tasks - Add text column with multiple lines Using Outlook 3
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
HarvMan Outlook 365 PST Report Using Outlook 1
V Upgraded Outlook Using Outlook 0
J Outlook 2010 Outlook/Win7 Client logging Event ID 36887 Using Outlook 0
R How to get the Items object of the default mailbox of a specific account in a multiple account Outlook? Outlook VBA and Custom Forms 0
Similar threads


















































Top