SUBFOLDER OF A SUBFOLDER

Status
Not open for further replies.

SiSept

New Member
Outlook version
Email Account
Exchange Server
I have a macro that sorts and moves mail into a subfolders according to category. I now want subfolders within the subfolders but I don't know how to write the instruction to move the mail - in this case 1st subfolder is AGENDA 05 MANAGEMENT then 2nd subfolder of 1st subfolder is PROJECTS 5.2 JOB REDESIGN:

If InStr(objItem.Categories, "AGENDAS 05 MANAGEMENT") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 05 MANAGEMENT")
cMAILS.Add objItem.EntryID
End If


If InStr(objItem.Categories, "PROJECTS 5.2 JOB REDESIGN") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 5.2 JOB REDESIGN")
cMAILS.Add objItem.EntryID
End If

I get an error message on the second instruction
 
this should work -
MyItem.Move FolderInbox.Folders("AGENDAS 05 MANAGEMENT").Folders("PROJECTS 5.2 JOB REDESIGN")

but its best to avoid so many dots in the path - something like would be better - it also makes it easier if you have a lot of subfolders under the agenda folder.
Code:
set agendaFolder -= FolderInbox.Folders("AGENDAS 05 MANAGEMENT")

If InStr(objItem.Categories, "AGENDAS 05 MANAGEMENT") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move agendaFolder 
cMAILS.Add objItem.EntryID
End If


If InStr(objItem.Categories, "PROJECTS 5.2 JOB REDESIGN") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move agendaFolder.Folders("PROJECTS 5.2 JOB REDESIGN")
cMAILS.Add objItem.EntryID
End If
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Print email attachments when hit subfolder Outlook VBA and Custom Forms 1
K vba code to auto download email into a specific folder in local hard disk as and when any new email arrives in Inbox/subfolder Outlook VBA and Custom Forms 0
sophievldn Looking for a macro that moves completed items from subfolders to other subfolder Outlook VBA and Custom Forms 7
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
B Need to Copy an email to a subfolder Outlook VBA and Custom Forms 2
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
N Move emails of same conversation to same subfolder Using Outlook 6
D How to handle filing of emails from an Inbox Subfolder to a specific Public folder Using Outlook 1
S VBA Code to move mail items from search folder to inbox subfolder Outlook VBA and Custom Forms 4
N Move red and unflagged emails to subfolder Outlook VBA and Custom Forms 1
B Open a folder / subfolder of a PST in single click Outlook VBA and Custom Forms 4
L Any util add ons for navigating al mail subfolder Using Outlook 0
V Macro to open Public Folders subfolder? Outlook VBA and Custom Forms 1
T Unable to create contacts subfolder in EAS profile Using Outlook.com accounts in Outlook 6
M VBA code needed to move from Outlook 2010 subfolder to Symantec Vault subfolde Using Outlook 0
M How do I access a contact list subfolder in Outlook 2013? Using Outlook 5
O BCM 13 added leads to an outlook 13 contact subfolder BCM (Business Contact Manager) 1
K Save a received email in a mailbox subfolder which is the same as the @email Using Outlook 1
J Create new outlook task into task subfolder using vba Using Outlook 6
P Copy Contacts in a Public Folder to a Local Contacts Subfolder Outlook VBA and Custom Forms 6

Similar threads

Back
Top