Microsoft KB Archive/831363

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

Article ID: 831363

Article Last Modified on 11/11/2004

-

APPLIES TO


 * Microsoft Office Outlook 2003
 * Microsoft Collaboration Data Objects 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), &quot;Calendar&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderContacts), &quot;Contacts&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderDeletedItems), &quot;Deleted Items&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderDrafts), &quot;Drafts&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderInbox), &quot;Inbox&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderJournal), &quot;Journal&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderJunk), &quot;Junk E-mail&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderNotes), &quot;Notes&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderOutbox), &quot;Outbox&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderSentMail), &quot;Sent Items&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderSyncIssues), &quot;Sync Issues&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderConflicts), &quot;Conflicts&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderLocalFailures), &quot;Local Failures&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderServerFailures), &quot;Server Failures&quot; ChangeFolderName objOLSession.GetDefaultFolder(olFolderTasks), &quot;Tasks&quot; 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

Keywords: kbprb KB831363

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.