ComponentPro UltimateMail

      Creating a WinForms application

      Language Filter: AllSend comments on this topic to ComponentPro

      This tutorial will walk you through creating a WinForms application and add Imap control to it. Adding the Pop3 and Smtp Controls is similar to the Imap control. It also shows how to:

      • Drag and Drop Imap control from the Toolbox to your form.
      • Set Imap properties.

      Creating a new project and adding IMAP control to it

      1. Start the Visual Studio .NET.
      2. From File menu, choose New, then choose Project.
      3. From the Project Creation dialog box, choose either Visual C# Projects or Visual Basic Projects then choose Windows Application. Specify a name and a location for the project, then click OK.
      4. Drag and drop the Imap control from the Toolbox to the form.
        Another way is to add references to ComponentPro.Mail.dll, ComponentPro.Network.dll, ComponentPro.NetworkSecure.dll, and ComponentPro.Common.dll assemblies. Please see Installation instruction for C# and Installation instruction for VB.NET for more details.
      5. Now right click on the IMAP component icon (bound with red rectangle in the picture above) to show the context menu, click on the Properties... menu.
        Win Win
      6. Now make a quick application to test. Drag a Button onto the form.
      7. Add the following code to the button "OnClick" event handler. This code is for listing all mailboxes of an IMAP account.
        using System;
        using System.Text;
        using ComponentPro.Net;
        using ComponentPro.Net.Mail;
        // IMAP server information. 
        const string serverName = "myserver";
        const string user = "";
        const string password = "mytestpassword";
        const int port = 993;
        const SslSecurityMode securityMode = SslSecurityMode.Implicit;
        // Create a new instance of the Imap class.
        Imap client = new Imap();
        // Connect to the server.
        client.Connect(serverName, port, securityMode);
        // Login to the server.
        client.Authenticate(user, password);
        StringBuilder sb = new StringBuilder();
        FolderCollection list = client.ListFolders();
        for (int i = 0; i < list.Count; i++)
            sb.AppendFormat("{0} - {1}\r\n", i + 1, list[i].Name);
        // Show the folder list
        // Close the connection.
      8. Compile and execute the application by navigating to the Debug menu and choose Start. Click the button and you should see a message showing a list of found mailboxes of the IMAP account in the MessageBox.