Hi all,
I have this small requirement its E-mails movement from my Generic mail box to its sub folder as given in the below screen shot for your reference.
Could someone advice please .
attached is the screen shot for your reference .
Hi all,
I have this small requirement its E-mails movement from my Generic mail box to its sub folder as given in the below screen shot for your reference.
Could someone advice please .
attached is the screen shot for your reference .
This demonstrates how to reference a non-default inbox.
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
To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx
If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.
Hi Skatonni,
Thanks for your inputs on my request this is something I have been looking .
Hope code works fine , i did not test it because, before I execute this I need little dynamic , my apologies I should have said this before .
Code movies E-mails to destined folder as given but I wanted those E-mails to be moved to my destined folder when criteria met let’s say .
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
Attached are the screen shot for your reference .let me know if you want anything else.
I believe your question was answered. The addendum may not be answerable. Try a new question with an appropriate subject. Link to this one if you think it would help.
To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx
If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.
Hi mate .. yes it was in fact answered by you .. ok if you say so i will raise another question on my Addendum..
thanks for your help in this regards.
Hi mate ,
I have tested the code ,it is giving me error lets say. I have changed my destination folder to "Cases to be Raised" from "printed"
below is the code for your reference .
My source folder is now (CFS-NAPA) inbox to subfolder (cases to be raised).
can you please look into this
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") ==== here what folder name ideally I should be adding in . 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
Last edited by Hudson; 01-11-2017 at 09:11 AM. Reason: attched screen shot
Follow the path the same as if you were opening the tree manually.
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") Set myDestFolder = myInbox.Folders("Cases to be Raised") 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
To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx
If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.
Hi mate , I know I am asking for too much , can you take me through the code please , out of your busy time .
mat can we Disable events and let it be just sub program . because I want to run manually with my interest.
sorry for giving you trouble ..
This code is to be run manually. First select a mailitem. No need to open it. The selection will be used in
With this line there is no need to reference a Source folder. Note only one item is processed any more are ignored.Set myItem = ActiveExplorer.Selection.Item(1)
To reference the destination folder, the code walks its way from the top of the folder tree to the destination folder.
Set myInbox = Session.Folders("CFS-NAPA") Set myInbox = myInbox.Folders("Inbox") Set myDestFolder = myInbox.Folders("Cases to be Raised")
This moves the selected item
This displays the destination folder. It is not necessary.myItem.Move myDestFolder
Set ActiveExplorer.CurrentFolder = myDestFolder
To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx
If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.