You cannot rename default folders by using the Outlook 2003 object model

Article translations Article translations
Article ID: 831363 - View products that this article applies to.
Expand all | Collapse all

SYMPTOMS

When you try to change the name of a default folder by using the Microsoft Office Outlook 2003 object model, you receive the following error message:
You don't have appropriate permission to perform this operation.

CAUSE

The Outlook 2003 object model was intentionally changed so that you cannot rename default folders.

WORKAROUND

To work around this problem, you can use the Collaboration Data Object (CDO) 1.21s object library. This library is included with Office 2003, but this library is not installed in a typical setup.

The following Microsoft Visual Basic or Microsoft Visual Basic for Applications sample code shows how you can automate both Outlook and CDO to rename the default folders. All the default folders are not easy to access by using the CDO object library because constants are not defined for the folders. Therefore, this sample uses the Outlook object library to access each default folder, and then accesses each folder in CDO by using the EntryID property and the StoreID property of the folder that is obtained from the Outlook object model.

Note To use the following sample, you must reference the Microsoft Outlook 11.0 Object Library and the Microsoft CDO 1.21 Library.
Dim objOLApp As Outlook.Application
Dim objOLSession As Outlook.NameSpace
Dim objCDOSession As MAPI.Session

Sub ChangeDefaultFolderNames()
   ' Get the Outlook objects
   Set objOLApp = New Outlook.Application
   Set objOLSession = objOLApp.Session
   'Get the CDO objects, using the existing Outlook session for CDO logon
   Set objCDOSession = New MAPI.Session
   objCDOSession.Logon , , False, False
   ' Skip over any folders that might not be there. This is
   ' mainly for the SyncIssues folder (and the following three)
   ' because they are only available in cached Exchange mode.
   On Error Resume Next
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderCalendar), "Calendar"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderContacts), "Contacts"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderDeletedItems), "Deleted Items"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderDrafts), "Drafts"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderInbox), "Inbox"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderJournal), "Journal"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderJunk), "Junk E-mail"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderNotes), "Notes"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderOutbox), "Outbox"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderSentMail), "Sent Items"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderSyncIssues), "Sync Issues"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderConflicts), "Conflicts"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderLocalFailures), "Local Failures"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderServerFailures), "Server Failures"
   ChangeFolderName objOLSession.GetDefaultFolder(olFolderTasks), "Tasks"
   objCDOSession.Logoff
   Set objCDOSession = Nothing
   Set objOLSession = Nothing
   Set objOLApp = Nothing
End Sub


Sub ChangeFolderName(objOLFolder As Outlook.MAPIFolder, strNewName As String)
   Dim objCDOFolder As MAPI.Folder
   ' Reference the folder by using CDO
   Set objCDOFolder = objCDOSession.GetFolder(objOLFolder.EntryID, objOLFolder.StoreID)
   ' Change the folder's name
   objCDOFolder.Name = strNewName
   ' Save changes to the folder
   objCDOFolder.Update
   Set objCDOFolder = Nothing
End Sub

Properties

Article ID: 831363 - Last Review: November 11, 2004 - Revision: 1.3
APPLIES TO
  • Microsoft Office Outlook 2003
  • Microsoft Collaboration Data Objects 1.21
Keywords: 
kbprb KB831363

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com