Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I create a New Outlook Folder in Code

Outlook VBA

How can I create a New Outlook Folder in Code

by  Chance1234  Posted    (Edited  )
Code:
Public Sub psubSetUpFoldersInOutlook()
Dim oloUtlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim itm As Object

On Error Resume Next

Application.ScreenUpdating = False

Set oloUtlook = CreateObject("Outlook.Application")
Set ns = oloUtlook.GetNamespace("MAPI")
Set itm = ns.GetDefaultFolder(olFolderInbox)

itm.Folders.Add ("Name of Folder You want To add")

Set oloUtlook = Nothing
Set ns = Nothing
Set itm = Nothing

MsgBox "Outlook Set Up Succesfully"
ThisWorkbook.Close


End Sub

Remember to reference the outlook object if you are using this code from a different application.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top