Tocogroup
asked on
How do I create a subfolder in Outlook from an Excel VBA application ?
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....
Many thanks
Toco
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
Many thanks
Toco
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER