Solved

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

Posted on 2014-01-18
2
1,143 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 30

Accepted Solution

by:
gowflow earned 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remaiā€¦
Read this checklist to learn more about the 15 things you should never include in an email signature.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

732 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