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?
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: