SUBFOLDER OF A SUBFOLDER

SiSept

New Member
Outlook version
Outlook 2007
Email Account
Exchange Server
#1
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
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#2
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
 
Top