Creates a mail folder on IMAP4/MS Exchange server.
[Visual Basic]
Public Function CreateFolder( _
    root As Imap4Folder, _
    folderName As String _
) As Imap4Folder
Public Async Function CreateFolderAsync( _
    root As Imap4Folder, _
    folderName As String _
) As Task (Of Imap4Folder)
    
[C#]
public Imap4Folder CreateFolder(
    Imap4Folder root,
    String folderName
);
public async Task<Imap4Folder> CreateFolderAsync(
    Imap4Folder root,
    String folderName
);
    
[C++]
public: Imap4Folder^ CreateFolder(
    Imap4Folder^ root,
    String folderName
);
    
[JScript]
public function CreateFolder( 
    root: Imap4Folder,
    folderName: String
) : Imap4Folder ;
    Parameters
Return Value
Example
[Visual Basic, C#, C++] The following example demonstrates how to create, subscribe, unsubscribe and delete "TestFolder" with EAGetMail POP3 & IMAP Component. To get the full samples of EAGetMail, please refer to Samples section.
[VB - Create/delete/subscribe/unsubscribe folder]
Imports System
Imports System.Globalization
Imports System.IO
Imports System.Text
Imports EAGetMail
Public Class TestClass
    ' if you want to search sub folder, use parentfolder\subfolder as folderPath
    ' for example: inbox\mysubfolder
    Function FindFolder(ByVal folderPath As String, ByRef folders As Imap4Folder()) As Imap4Folder
        For i As Integer = 0 To folders.Length - 1
            Dim folder As Imap4Folder = folders(i)
            ' Folder was found.
            If String.Compare(folder.LocalPath, folderPath, True) = 0 Then
                Return folder
            End If
            folder = FindFolder(folderPath, folder.SubFolders)
            If Not (folder Is Nothing) Then
                Return folder
            End If
        Next
        ' No folder found
        Return Nothing
    End Function
    Public Sub CreateDeleteFolder(server As String, user As String, password As String, useSsl As Boolean)
        Try
            ' ExchangeEWS Or ExchangeWebDAV protocol also supports folder operation.
            ' Most modern email server require SSL/TLS connection, 
            ' set useSsl to true Is recommended.
            Dim oServer As New MailServer(server, user, password, useSsl,
                        ServerAuthType.AuthLogin, ServerProtocol.Imap4)
            ' IMAP4 port Is 143,  IMAP4 SSL port Is 993.
            ' EWS/WebDAV, please ignore Port property.
            oServer.Port = If(useSsl, 993, 143)
            Console.WriteLine("Connecting server ...")
            Dim oClient As New MailClient("TryIt")
            oClient.Connect(oServer)
            ' Create a test folder
            Dim folder As Imap4Folder = oClient.CreateFolder(Nothing, "TestFolder")
            ' Only IMAP4 protocol supports SubscribeFolder
            If oServer.Protocol = ServerProtocol.Imap4 Then
                If Not folder.Subscribed Then
                    oClient.SubscribeFolder(folder)
                End If
            End If
            ' List existed root folders on server
            Dim folders() As Imap4Folder = oClient.GetFolders()
            For i As Integer = 0 To folders.Length - 1
                Dim fd As Imap4Folder = folders(i)
                Console.WriteLine("folder: {0}", fd.LocalPath)
            Next
            ' Only IMAP4 protocol supports UnsubscribeFolder
            If oServer.Protocol = ServerProtocol.Imap4 Then
                oClient.UnsubscribeFolder(folder)
            End If
            ' Delete test folder
            oClient.DeleteFolder(folder)
            oClient.Logout()
            Console.WriteLine("Completed!")
        Catch ep As Exception
            Console.WriteLine(ep.Message)
        End Try
    End Sub
End Class
[C# - Create/delete/subscribe/unsubscribe folder]
using System;
using System.IO;
using System.Globalization;
using System.Text;
using EAGetMail;
class TestClass
{
    // if you want to search sub folder, use parentfolder\subfolder as folderPath
    // for example: inbox\mysubfolder
    static Imap4Folder FindFolder(string folderPath, Imap4Folder[] folders)
    {
        int count = folders.Length;
        for (int i = 0; i < count; i++)
        {
            Imap4Folder folder = folders[i];
            if (string.Compare(folder.LocalPath, folderPath, true) == 0)
            {
                return folder;
            }
            folder = FindFolder(folderPath, folder.SubFolders);
            if (folder != null)
            {
                return folder;
            }
        }
        // No folder found
        return null;
    }
    
    public void CreateDeleteFolder(string server, string user, string password, bool useSsl)
    {
        try
        {
            // ExchangeEWS Or ExchangeWebDAV protocol also supports folder operation.
            // Most modern email servers require SSL/TLS connection, 
            // set useSsl to true is recommended.
            MailServer oServer = new MailServer(server, user, password, useSsl,
                ServerAuthType.AuthLogin, ServerProtocol.Imap4);
            // IMAP4 port is 143,  IMAP4 SSL port is 993.
            // EWS/WebDAV, please ignore Port property.
            oServer.Port = (useSsl) ? 993 : 143;
            Console.WriteLine("Connecting server ...");
            MailClient oClient = new MailClient("TryIt");
            oClient.Connect(oServer);
            // Create a test folder.
            Imap4Folder folder = oClient.CreateFolder(null, "TestFolder");
            // Only IMAP4 protocol supports SubscribeFolder
            if (oServer.Protocol == ServerProtocol.Imap4)
            {
                if (!folder.Subscribed)
                { 
                    oClient.SubscribeFolder(folder);
                }
            }
            // List existed root folders on server
            Imap4Folder[] folders = oClient.GetFolders();
            for (int i = 0; i < folders.Length; i++)
            {
                Imap4Folder fd = folders[i];
                Console.WriteLine("folder: {0}", fd.LocalPath);
            }
            // Only IMAP4 protocol supports UnsubscribeFolder
            if (oServer.Protocol == ServerProtocol.Imap4)
            {
                oClient.UnsubscribeFolder(folder);
            }
            // Delete test folder
            oClient.DeleteFolder(folder);
            oClient.Logout();
            Console.WriteLine("Completed!");
        }
        catch (Exception ep)
        {
            Console.WriteLine("Error: {0}", ep.Message);
        }
    }
}
[C++/CLI - Create/delete/subscribe/unsubscribe folder]
using namespace System;
using namespace System::Globalization;
using namespace System::IO;
using namespace EAGetMail; //add EAGetMail namespace
// if you want to search sub folder, use parentfolder\\subfolder as folderPath
// for example: inbox\\mysubfolder
Imap4Folder^ FindFolder(String^ folderPath, array<Imap4Folder^> ^folders)
{
    for (int i = 0; i < folders->Length; i++)
    {
        Imap4Folder^ folder = folders[i];
        // Folder was found.
        if (String::Compare(folder->LocalPath, folderPath, true) == 0)
            return folder;
        folder = FindFolder(folderPath, folder->SubFolders);
        if (folder != nullptr)
            return folder;
    }
    // No folder found
    return nullptr;
}
void CreateDeleteFolder(String ^server, String ^user, String ^password, bool useSsl)
{
    try
    {
        // ExchangeEWS or ExchangeWebDAV protocol also supports folder operation.
        // Most modern email servers require SSL/TLS connection, 
        // set useSsl to true is recommended.
        MailServer ^oServer = gcnew MailServer(server, user, password, useSsl,
            ServerAuthType::AuthLogin, ServerProtocol::Imap4);
        // IMAP4 port is 143,  IMAP4 SSL port is 993.
        // EWS/WebDAV, please ignore Port property.
        oServer->Port = (useSsl) ? 993 : 143;
        Console::WriteLine("Connecting server ...");
        MailClient ^oClient = gcnew MailClient("TryIt");
        oClient->Connect(oServer);
        // Create a test folder
        Imap4Folder ^ folder = oClient->CreateFolder(nullptr, "TestFolder");
        // Only IMAP4 protocol supports SubscribeFolder
        if (oServer->Protocol == ServerProtocol::Imap4)
        {
            if (!folder->Subscribed)
                oClient->SubscribeFolder(folder);
        }
        // List existed root folders on server.
        array<Imap4Folder^> ^folders = oClient->GetFolders();
        for (int i = 0; i < folders->Length; i++)
        {
            Imap4Folder ^fd = folders[i];
            Console::WriteLine("folder: {0}", fd->FullPath);
        }
        // Only IMAP4 protocol supports UnsubscribeFolder
        if (oServer->Protocol == ServerProtocol::Imap4)
        {
            oClient->UnsubscribeFolder(folder);
        }
        // Delete test folder
        oClient->DeleteFolder(folder);
        oClient->Logout();
        Console::WriteLine("Completed!");
    }
    catch (Exception ^ep)
    {
        Console::WriteLine("Error: {0}", ep->Message);
    }
}
    See Also
        MailClient.RenameFolder
        MailClient.DeleteFolder
         MailClient.SubscribeFolder
         MailClient.UnsubscribeFolder