Renaming Outlook System folders Part 1 (VB Script)

‘ RenFldr – Rename Outlook “Special Folders”
‘ (c) Neo (n…@mvps.org)
‘ 11.11.2000, v.1.0
‘ 11.06.2002, v.1.1

‘ Test System
‘ Windows Script Host v.
‘ VBScript v.
‘ Outlook 2000 (SR1a)
‘ Windows 2000 (SP1)

‘ Change Log
‘ 11.11.2000 – Creation Date
‘ 11.06.2002 – Added support drafts folder

Const olFolderDeletedItems = 3
Const olFolderOutbox = 4
Const olFolderSentItems = 5
Const olFolderInbox = 6
Const olFolderCalendar = 9
Const olFolderContacts = 10
Const olFolderJournal = 11
Const olFolderNotes = 12
Const olFolderTasks = 13
Const olFolderDrafts = 16

Dim Engine
Dim Outlook
Dim Folder

Select Case UCase(Right(WScript.FullName, 11))
Case “WSCRIPT.EXE”
Engine = “W”
Case “CSCRIPT.EXE”
Engine = “C”
End Select

Set Args = WScript.Arguments

If Args.Count = 0 Then
DisplayHelp()
WScript.Quit
End If

If Args.Item(0) = “-?” Or Args.Item(0) = “/?” Or Args.item(0) = “?” Then
DisplayHelp()
WScript.Quit
End If

If Args.Count <> 2 Then
DisplayHelp()
WScript.Quit
End If

Set Outlook = CreateObject(“Outlook.Application”)
Set Folder = Nothing

Select Case UCase(Args.Item(0))
Case “CALENDAR”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderCalendar)
Case “INBOX”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderInbox)
Case “OUTBOX”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderOutbox)
Case “SENTITEMS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderSentItems)
Case “DELETEDITEMS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderDeletedItems)
Case “CONTACTS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderContacts)
Case “JOURNAL”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderJournal)
Case “NOTES”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderNotes)
Case “TASKS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderTasks)
Case “DRAFTS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderDrafts)
Case Else
DisplayHelp()
End Select

If Folder Is Nothing Then
WScript.Quit
End If

Folder.Name = Args.Item(1)

Set Folder = Nothing
Set Outlook = Nothing

Sub DisplayHelp()
If Engine = “W” Then
MsgBox “RenFldr:” & vbCRLF &_
” Change Name of Default Folders” & vbCRLF & vbCRLF &_
“Usage: RenFldr Folder NewName” & vbCRLF & vbCRLF &_
” Supported values for Folder:” & vbCRLF &_
” Inbox” & vbCRLF &_
” Outbox” & vbCRLF &_
” Calendar” & vbCRLF &_
” SentItems” & vbCRLF &_
” DeletedItems” & vbCRLF &_
” Contacts” & vbCRLF &_
” Journal” & vbCRLF &_
” Notes” & vbCRLF &_
” Tasks” & vbCRLF &_
” Drafts”
Else
WScript.StdOut.WriteLine “RenFldr:”
WScript.StdOut.WriteLine ” Change Name of Default Folders” & vbCRLF
WScript.StdOut.WriteLine “Usage: RenFldr Folder NewName” & vbCRLF
WScript.StdOut.WriteLine ” Supported values for Folder:”
WScript.StdOut.WriteLine ” Inbox”
WScript.StdOut.WriteLine ” Outbox”
WScript.StdOut.WriteLine ” Calendar”
WScript.StdOut.WriteLine ” SentItems”
WScript.StdOut.WriteLine ” DeletedItems”
WScript.StdOut.WriteLine ” Contacts”
WScript.StdOut.WriteLine ” Journal”
WScript.StdOut.WriteLine ” Notes”
WScript.StdOut.WriteLine ” Tasks”
WScript.StdOut.WriteLine ” Drafts”
End If
End Sub

Comments

Leave a Reply

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)