Hudson
01-10-2017, 01:17 PM
Hi all,
I have code that does a quick job of moving E-mails from Generic (napa) INBOX email box to its sub folder PRINTED FOLDER effectively . here my challenge is not every mail should go to sub folder , but only when a criteria met and my criteria is as follows.
I wanted those mails with text inside the PDF attachment saying .
X7 below $250 to be moved to printed mail box
XB below $250 to be moved to printed mail box
please find below code that was obtained from the same forum in my errlier question .
Option Explicit
Private Sub MoveToFolder()
Dim myInbox As Folder
Dim myDestFolder As Folder
Dim myItem As mailItem
Set myInbox = Session.Folders("CFS-NAPA")
Set myInbox = myInbox.Folders("Inbox") ' Not the default olFolderInbox
Set myDestFolder = myInbox.Folders("Name of folder under the red line")
Set myDestFolder = myDestFolder.Folders("Printed")
Set myItem = ActiveExplorer.Selection.Item(1)
Debug.Print myItem.Subject
myItem.Move myDestFolder
Set ActiveExplorer.CurrentFolder = myDestFolder
ExitRoutine:
Set myInbox = Nothing
Set myDestFolder = Nothing
Set myItem = Nothing
End Sub
Attached are the screen shot for your reference .let me know if you want anything else.
I have code that does a quick job of moving E-mails from Generic (napa) INBOX email box to its sub folder PRINTED FOLDER effectively . here my challenge is not every mail should go to sub folder , but only when a criteria met and my criteria is as follows.
I wanted those mails with text inside the PDF attachment saying .
X7 below $250 to be moved to printed mail box
XB below $250 to be moved to printed mail box
please find below code that was obtained from the same forum in my errlier question .
Option Explicit
Private Sub MoveToFolder()
Dim myInbox As Folder
Dim myDestFolder As Folder
Dim myItem As mailItem
Set myInbox = Session.Folders("CFS-NAPA")
Set myInbox = myInbox.Folders("Inbox") ' Not the default olFolderInbox
Set myDestFolder = myInbox.Folders("Name of folder under the red line")
Set myDestFolder = myDestFolder.Folders("Printed")
Set myItem = ActiveExplorer.Selection.Item(1)
Debug.Print myItem.Subject
myItem.Move myDestFolder
Set ActiveExplorer.CurrentFolder = myDestFolder
ExitRoutine:
Set myInbox = Nothing
Set myDestFolder = Nothing
Set myItem = Nothing
End Sub
Attached are the screen shot for your reference .let me know if you want anything else.