Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

INFO: Logging On to Exchange by Using CDO Can Create Default Folders


View products that this article applies to.

This article was previously published under Q284604

↑ Back to the top


Summary

When you use Collaboration Data Objects (CDO) to log on to a mailbox and access any Outlook default folder, all Outlook default folders are created if they do not already exist.

↑ Back to the top


More information

When a new mailbox is created on Exchange Server, the only folders that Exchange creates are the Inbox, Outbox, Deleted Items, and Sent Items folders. The default Outlook folders (Calendar, Contacts, Tasks, Drafts, and Journal) are not created. The first time the Outlook client logs onto the mailbox, Outlook creates these folders.

You may want to create these folders before the Outlook client first logs on to the mailbox. To do this, log on to the mailbox with CDO and access one of the default folders. If they are not present, all of the Outlook folders are created by this attempt.

To do this, follow these steps:
  1. Create a new mailbox on your Exchange server.
  2. Log on to the new mailbox by using Mdbvu32.exe.
  3. Browse to Top of Information Store. Under Child Folders, you see Inbox, Outbox, Sent Items, and Deleted Items. The other default folders are not present at this time.
  4. In Microsoft Visual Basic, create a new Standard EXE project, and add a reference to the CDO 1.21 library.
  5. Add a button to the form, and paste the following code in the button's Click event:
    Private Sub cmdCreateCalendar_Click()
        Dim oSession As MAPI.Session
        Dim strProfile As String
        Dim oCalendar As MAPI.Folder
        
        Set oSession = CreateObject("MAPI.Session")
        ' TO DO:
        ' Be sure to replace "server_name" with the name of your Exchange server
        ' and replace "mailbox_alias" with the alias of your newly created mailbox.
        strProfile = "server_name" & vbLf & "mailbox_alias"
        
        oSession.Logon , , False, True, , True, strProfile
        ' Default folders are created when the next line is called.
        Set oCalendar = oSession.GetDefaultFolder(CdoDefaultFolderCalendar)
        oSession.Logoff
        
        Set oCalendar = Nothing
        
        Set oSession = Nothing
        
    End Sub
    					
  6. Run the project, click the button to run the code, and then close the program.
  7. Log on to the mailbox again by using Mdbvu32.exe. Browse to Top of Information Store. Now, under Child Folders, you see all of the Outlook default folders.
NOTE: The sample code accesses the Calendar folder, but you can also do this by accessing any of the following default folders:
  • CdoDefaultFolderCalendar
  • CdoDefaultFolderContacts
  • CdoDefaultFolderJournal
  • CdoDefaultFolderNotes
  • CdoDefaultFolderTasks

↑ Back to the top


Keywords: KB284604, kbmsg, kbinfo

↑ Back to the top

Article Info
Article ID : 284604
Revision : 6
Created on : 2/22/2007
Published on : 2/22/2007
Exists online : False
Views : 421