Forward E-Mails as They Are Sorted

I often find myself creating a folder to store all the messages relating to a particular project, and then wanting to forward any message placed in that folder to one of my colleagues. This code, when placed in the ThisOutlookSession module, takes care of the forwarding for me.

This code was derived from Sue Mosher’s article found in Windows & .Net Magazine.

``VBScript ‘ Copyright under GPL by Mark Grimes

Option Explicit

Private WithEvents objEconomistItems As Items

‘ instantiate Items collections for folders we want to monitor Private Sub Application_Startup() Dim objNS As NameSpace Set objNS = Application.GetNamespace(“MAPI”)

Set objEconomistItems = objNS.GetDefaultFolder(olFolderInbox).Folders.Item("Mailing Lists").Folders.Item("Economist").Items
Set objNS = Nothing

End Sub

‘ disassociate global objects declared WithEvents Private Sub Application_Quit() Set objEconomistItems = Nothing End Sub

‘ Forward msg when new msg added to folder ‘ Prompt before sending Private Sub objEconomistItems_ItemAdd(ByVal Item As Object) Dim Response As Variant Dim myForward As Variant

Response = MsgBox("Forward message (" + Item.Subject + ") to Patrick & Josh?", vbYesNo)
If Response = vbYes Then
    Set myForward = Item.Forward
    myForward.Recipients.Add "Patrick (E-mail)"
    myForward.Recipients.Add "Josh (E-Mail)"
End If

End Sub ```


July 25, 2005 6:36AM


The contents of this blog are licensed under the Creative Commons “Attribution-Noncommercial-Share Alike 3.0″ license.