PDA

View Full Version : [SOLVED:] Mail movment from genric folder to subfolders



Hudson
01-09-2017, 11:30 AM
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 .

skatonni
01-09-2017, 03:06 PM
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

Hudson
01-10-2017, 05:59 AM
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.

skatonni
01-10-2017, 11:16 AM
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.

Hudson
01-10-2017, 12:52 PM
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.

Hudson
01-11-2017, 09:09 AM
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

skatonni
01-11-2017, 10:21 AM
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

Hudson
01-11-2017, 11:03 AM
Hi mate , I know I am asking for too much , can you take me through the code please , out of your busy time .

Hudson
01-11-2017, 12:04 PM
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 ..

skatonni
01-16-2017, 09:45 AM
This code is to be run manually. First select a mailitem. No need to open it. The selection will be used in


Set myItem = ActiveExplorer.Selection.Item(1)

With this line there is no need to reference a Source folder. Note only one item is processed any more are ignored.

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


myItem.Move myDestFolder

This displays the destination folder. It is not necessary.


Set ActiveExplorer.CurrentFolder = myDestFolder