[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Create folders in outlook from a text file.I want to create 20 folders in outlook below inbox

Posted on 2007-07-27
Medium Priority
Last Modified: 2010-03-05

Create folders in outlook from a text file.I want to create 20 folders in outlook below inbox.So need a way to do this automatically.I have all the folder names in the txt file.

Question by:bsharath
  • 2
LVL 19

Accepted Solution

weellio earned 2000 total points
ID: 19583949
Sub do_it()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\test.txt", 1)
Do Until objFile.AtEndOfStream
    strName = objFile.Readline
    createfolder (strName)
End Sub

Function createfolder(strAttFldName)
  Dim objInbox As MAPIFolder
  Dim objNS As NameSpace
'  strAttFldName = bob
  On Error Resume Next
  Set objNS = Application.GetNamespace("MAPI")
  Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
  Set objAttFld = objInbox.Folders(strAttFldName)
  Set objAttFld = objInbox.Folders.Add(strAttFldName)
  On Error GoTo 0
  Set objAttFld = Nothing
  Set objInbox = Nothing
  Set objNS = Nothing
  Set objAtt = Nothing
End Function
LVL 11

Author Comment

ID: 19586017
Where should i run this script and where should i put the folder names.
LVL 19

Expert Comment

ID: 19586313
open outlook
tools - macros
type a name in the top field.

click create
paste the script from above.

once pasted, then close visual editor
and goto tools macros - and run the "do_it" macro

this line from the script above says the location it can be changed to wherever you want
currently c:\test.txt
Set objFile = objFSO.OpenTextFile("C:\test.txt", 1)


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article covers how to install the Microsoft Windows Operating System (OS). What is covered in this article:  > Different Versions and Editions of the Windows OS  > Upgrading versus Fresh Installation of the OS           - Steps to take pr…
Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

873 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