|
|
|
|
|
|
Outlook
|
Mail Notification for different folders
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2000, 2002, 2003
|
Submitted by:
|
Steiner
|
Description:
|
Brings up a messagebox if a mail arrives in any given folder (not just the default inbox), even if this mail was just moved there.
|
Discussion:
|
This can be helpful if you have more than 1 postbox you need to monitor. Or if you use a folder where many people can move mails into (instead of sending them) and you want to be notified of a new one.
|
Code:
|
instructions for use
|
Option Explicit
Private Fold1 As Outlook.MAPIFolder
Private WithEvents colItems1 As Outlook.Items
Private Sub Application_Startup()
Set Fold1 = Application.GetNamespace("MAPI").Folders("My Postbox").Folders("Inbox")
Set colItems1 = Fold1.Items
End Sub
Private Sub colItems1_ItemAdd(ByVal Item As Object)
MsgBox "New mail from " & item.sendername & " in " & Fold1.Parent.Name
End Sub
Private Sub Application_Quit()
Set Fold1 = Nothing
Set colItems1 = Nothing
End Sub
|
How to use:
|
- Open the VBA-Editor (Alt + F11)
- Open the Project Explorer (Ctrl + R)
- There search for Projekt1 - Microsoft Outlook Object - ThisOutlookSession
- Insert the code there
- Modify the line Set Fold1 = to match the folder you want to monitor, you'll need the whole path as shown in the Outlook folderlist, so just "Inbox" might not be enough, you'll have to use the whole path. If you need to go deeper, just add another .Folders("foldername")
- Save this and restart Outlook so the Startup-Method get's fired
|
Test the code:
|
- As I don't know your foldernames an example does not make much sense, sorry!
- So just proceed as described above.
- Don't forget to change the folder names to match your settings.
- Send or simply move a mail to the folder you just specified.
- Now you should get a messagebox telling you about the new mail.
|
Sample File:
|
No Attachment
|
Approved by Zack Barresse
|
This entry has been viewed 263 times.
|
|