Open unread mail dropped in a subfolder automatically using VB

Joined
Jun 17, 2009
Messages
3
Reaction score
0
I have a code that moves a message to a specified folder based on tagging properties and marks it as unread, what I need to do is once it gets to that folder, I need VB to open it so I can have a program initiate a printing and filing process.



We just need to have the email opened up automatically once it hits the folder. I have developed the following code in the ThisOutlookSession and it works fine on the Inbox, but we need it to run on a subfolder, and we need it to run all of the time.


Private WithEvents olInboxItems As Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.Session
' initiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items

'Set olInboxItems = objNS.FolderPath("Mailbox - Owsley, Caleb").Folders.Item("Inbox").Folders.Item("Create PDF")

Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
On Error Resume Next
Item.Display 'True
'Item.Save
Set Item = Nothing
End Sub


The text in bold above, i thought would work, but it does not, however, this is the folder i need to monitor...

so based off of the above code, when a new email arives to the inbox, it will open it, but I need to get it to initiate only when a new item is added into the following location:

FolderPath:

("Mailbox - Owsley, Caleb").Folders.Item("Inbox").Folders.Item("CreatePDF")

Any help on this is GREATLY appreciated!

Also is there a way to get this to run outside of the "ThisOutlookSession" and into a module?
 
Last edited:
Note, I am running Outlook 2007



Note, I am very new to VB so my knowledge is limited... I think it is incorrect to use olInboxItems in this situation, but I am not sure what to use in its place, or sure how to run this on a subfolder :(
 
Last edited:
Back
Top