PDA

View Full Version : Move email from genric folder to subfolder when email attchment met with criteria



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.

Hudson
01-11-2017, 08:08 AM
Hi can some one advice please . can that be done, I mean am I asking for more over the forum ?.