?
Solved

How do I create a subfolder in Outlook from an Excel VBA application ?

Posted on 2014-01-18
2
Medium Priority
?
1,229 Views
Last Modified: 2014-01-19
Hi All,

I have an Excel VBA application in which I open Outlook and create a folder. However, I would like to create a subfolder from the main folder but don't seem to be able to do so. Can anyone help ? My current code is below....

   Answer = MsgBox("Create a new Outlook folder ?", vbYesNoCancel)
   
   If Answer = vbYes Then
      OutlookFolderName = teOrderNo & " " & coClientName & " - " & coHeading
      
      Set ol = CreateObject("Outlook.Application")
      Set ns = ol.GetNamespace("MAPI")
      ParentFolder = "Personal Folders"
      MainFolder = "_Toco Orders"
      Set fl = ns.Folders.Item(ParentFolder).Folders.Item(MainFolder)
      fn = OutlookFolderName
   
      If Len(fn) > 0 Then
         Set mf = fl.Folders.Add(fn)
         Set mf = Nothing
         Set fl = Nothing
         Set ns = Nothing
         Set ol = Nothing
         MsgBox "A new Outlook folder has been created successfully", vbInformation
      End If
            
   End If

Open in new window


Many thanks
Toco
0
Comment
Question by:Tocogroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
gowflow earned 2000 total points
ID: 39790988
Well here is how to add a folder:

' Create a new mail folder named "Important Items".
Set fl = ns.Folders.Item(ParentFolder).Folders.Item(MainFolder).Folders.Add("Important Items")


gowflow
0
 

Author Closing Comment

by:Tocogroup
ID: 39791907
Ah yes. That's great. Many thanks.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
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: …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Suggested Courses

762 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