rogerdjr
asked on
Outlook exchange Office 365 - Add a Subfolder to a "non'Default Folder"
I found this code to add a subfolder to the inbox default folder
Sub AddInboxProjectsSubFolder( )
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olNewFolder As Outlook.MAPIFolder
Dim msg As Outlook.MailItem
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set olFolder = objNS.GetDefaultFolder(olF olderInbox )
Set olNewFolder = olFolder.Folders.Add("1604 3 Fuel Island Repair")
End Sub
The attached .pdf shows my outlook folder structure and I would like to adapt this code to add subfolders to the Projects folder
Using Outlook exchange with office 365
Sub AddInboxProjectsSubFolder(
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olNewFolder As Outlook.MAPIFolder
Dim msg As Outlook.MailItem
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set olFolder = objNS.GetDefaultFolder(olF
Set olNewFolder = olFolder.Folders.Add("1604
End Sub
The attached .pdf shows my outlook folder structure and I would like to adapt this code to add subfolders to the Projects folder
Using Outlook exchange with office 365
no attachment
ASKER
Not sure what happened
What I want to do is add subfolders to the Projects folder rather than the inbox
C--Users-Roger-Documents-Outlook-Fol.JPG
What I want to do is add subfolders to the Projects folder rather than the inbox
C--Users-Roger-Documents-Outlook-Fol.JPG
msdn... for GetDefaultFolder
Remarks
To return a specific non-default folder, use the Folders collection.
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
'--- need to trap error if not exist
Set olFolder = objNS.Folders("Projects")
if(err.number>0) then
Set olFolder = objNS.Folders.Add("Projects")
end if
newfoldername = "16043 Fuel Island Repair"
Set olNewFolder = olFolder.Folders.Add(newfoldername )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great solution - thanks for the help