Hi
I have Outlook 2010. I'm trying to write code that will print an email when it is moved into a folder. That bit I have managed, and it works fine. However that is when moving an email into the folder "Worldox" which sits at the same level as Inbox. I can't seem to work out how to code it so that it works when moving mail into a subfolder of "Worldox", eg into "Joey"
The other issue is that the subfolders may be added/deleted/renamed so to future proof the code it would be helpful if it could print when mail is moved into any subfolder of "Worldox" Is that possible?
The code that I have so far is
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Parent.Folders("Worldox").Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next
Mail.PrintOut
End Sub
I'm not very good with VB so any help would be very much appreciated!