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



The information in this article applies to:

  • Microsoft Office Outlook 2003
  • Collaboration Data Objects (CDO) 1.21


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

Modification Type:MajorLast Reviewed:11/11/2004
Keywords:kbprb KB831363 kbAudDeveloper