共用方式為


HOW TO:建立自訂資料夾項目

這個範例會在 Microsoft Office Outlook 中建立新的資料夾。 會使用登入使用者的名稱做為資料夾名稱。

**適用於:**本主題中的資訊適用於 Outlook 2007 和 Outlook 2010 的應用程式層級專案。如需詳細資訊,請參閱依 Office 應用程式和專案類型提供的功能

範例

Private Sub CreateNewFolder()
    Dim inBox As Outlook.MAPIFolder = Me.Application.ActiveExplorer().Session. _
        GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    Dim userName As String = Me.Application.ActiveExplorer() _
        .Session.CurrentUser.Name
    Dim customFolder As Outlook.MAPIFolder
    Try
        customFolder = inBox.Folders.Add(userName, Outlook _
           .OlDefaultFolders.olFolderInbox)
        MsgBox("You have created a new folder named " _
            & userName & ".")
        inBox.Folders(userName).Display()
    Catch ex As Exception
        MsgBox("The following error occurred: " & ex.Message)
    End Try
End Sub
private void CreateCustomFolder()
{
    Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
        this.Application.ActiveExplorer().Session.GetDefaultFolder
        (Outlook.OlDefaultFolders.olFolderInbox);
    string userName = (string)this.Application.ActiveExplorer()
        .Session.CurrentUser.Name;
    Outlook.MAPIFolder customFolder = null;
    try
    {
        customFolder = (Outlook.MAPIFolder)inBox.Folders.Add(userName,
            Outlook.OlDefaultFolders.olFolderInbox);
        MessageBox.Show("You have created a new folder named " +
            userName + ".");
        inBox.Folders[userName].Display();
    }
    catch (Exception ex)
    {
        MessageBox.Show("The following error occurred: " + ex.Message);
    }
}

請參閱

工作

HOW TO:將項目加入至 Outlook 連絡人

HOW TO:建立約會

概念

使用資料夾