View Full Version : Automatically Run code when new message received
dicepackage
01-27-2011, 01:10 PM
I would like to configure something in Outlook so that every time a new message arrives in a certain folder it runs a script. I have a program to parse the subject of an e-mail but it has to do this manually. Is there anyway to automate this process so that once the e-mail comes in it will run my code. Another possible but less desired solution would be to have Outlook on a timer to run my code every so often.
JP2112
01-31-2011, 01:10 PM
Set up the rules wizard to run your code on incoming emails. You can use the following example code:
Sub CustomMailMessageRule(Item As Outlook.MailItem)
MsgBox "Mail message arrived: " & Item.Subject
End Sub
Call your custom function from within the procedure that is run by the rule.
dicepackage
01-31-2011, 01:37 PM
In the Outlook rules I do not see a message to check if a new message is in a folder, it will check for everything. Is there anyway to make it focus on a specific folder because this thing will be running constantly otherwise.
JP2112
01-31-2011, 02:11 PM
You may want to adapt this code instead:
http://www.vbaexpress.com/forum/showthread.php?t=35910
You would call your custom function from the Items_ItemAdd Event.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.