Solved

Outlook exchange Office 365 - Add a Subfolder to a "non'Default Folder"

Posted on 2016-08-02
  • Outlook
  • Exchange
  • Email Servers
  • MS Office
  • Office / Productivity
  • +2
6
89 Views
Last Modified: 2016-08-20
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(olFolderInbox)

    Set olNewFolder = olFolder.Folders.Add("16043 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
0
Comment
Question by:rogerdjr
  • 2
  • 2
6 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 41740413
no attachment
0
 

Author Comment

by:rogerdjr
ID: 41740639
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
0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 41763980
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 )

Open in new window

0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 41764004
actually Slipstick seems to recommend..
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
    Set olFolderTop = objNS.GetDefaultFolder(olFolderInbox).Parent  'get parent of inbox
  '--- need to trap error if not exist
    Set olFolder = olFolderTop.Folders("Projects")
   if(err.number>0) then
         Set olFolder = olFolderTop.Folders.Add("Projects")
   end if
   newfoldername = "16043 Fuel Island Repair"
    Set olNewFolder = olFolder.Folders.Add(newfoldername )

Open in new window

1
 

Author Closing Comment

by:rogerdjr
ID: 41764069
Great solution - thanks for the help
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now