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:
- Create a new mailbox on your Exchange server.
- Log on to the new mailbox by using Mdbvu32.exe.
- 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.
- In Microsoft Visual Basic, create a new Standard EXE project, and add a reference to the CDO 1.21 library.
- 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
- Run the project, click the button to run the code, and then close the program.
- 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