working on it ...

Filters

Explore Public Snippets

Sort by

Found 9,380 snippets matching: email

    public by pplant modified Jul 25, 2014  298567  3  6  2

    Simple e-mail validator

    This is a simple email validator which can be used in forms to check whether a given email address is valid or not.
    public static boolean isValidEmailAddress(String email) {
    	   boolean result = true;
    	   try {
    	      InternetAddress emailAddr = new InternetAddress(email);
    	      emailAddr.validate();
    	   } catch (AddressException ex) {
    	      result = false;
    	   }
    	   return result;
    }
    

    public by JackLatanis modified Nov 3, 2014  297764  6  6  -1

    Sending email via AuthMailer service using PHP

    //this code sends emails via AuthMailer service (www.authmailer.com)
    
    <?
    
    //install the Mail, Net_Socket and Net_SMTP with PEAR
    require_once "Mail.php";
     
    //mail headers and body
    $from = "Me";
    $to = "You";
    $subject = "Subject";
    $body = "Lorem Ipsum...";
    
    //server configuration, edit with your account details 
    $host = "authmailer.com";
    $port = "587";
    $user = "user";
    $pass = "pass";
     
    $headers = array('From' => $from,
    	'To' => $to,
    	'Subject' => $subject);
    
    $smtp = Mail::factory('smtp',
    	array('host' => $host,
    	'auth' => true,
    	'username' => $user,
    	'password' => $pass));
    
    //sending email
    $mail = $smtp->send($to, $headers, $body);
     
    if (PEAR::isError($mail)) 
    {
      //something went wrong
    	echo($mail->getMessage());
    } 
    else 
    {
      //OK
    	echo("Message was sent!");
    }
    
    ?>

    public by cghersi @ MailUp API DEV modified Jan 20, 2015  206772  8  6  1

    MailUp REST API - How to subscribe to a particular list several contacts with the "Confirmed Optin" Procedure

    This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication. You can start digging into the MailUP API world by reading this content: http://help.mailup.com/display/mailupapi/REST+API An instance of MailUpClient class is able to manage one user at a time. A MailU
    public static void SubcribeRecipientsWithDoubleOptin(string clientID, string clientSecret, string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient(clientID, clientSecret);
        try
        {
            client.RetrieveAccessToken(username, password);
        }
        catch (MailUpException ex)
        {
            Console.WriteLine("Unable to access the service due to " + ex.Message);
            return;
        }
    
        // 2) Subscribe recipients:
        int idList = 1;
        List<ConsoleRecipientItem> recipients = new List<ConsoleRecipientItem>();
        ConsoleRecipientItem recipient1 = new ConsoleRecipientItem()
        {
            Email = "test1@mailup.com",
            Name = "First New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3331234567",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        ConsoleRecipientItem recipient2 = new ConsoleRecipientItem()
        {
            Email = "test2@mailup.com",
            Name = "Second New Recipient" + DateTime.Now.ToFileTimeUtc(),
            MobileNumber = "3337654321",
            MobilePrefix = "39",
            Fields = new List<ConsoleRecipientDynamicFieldItem>()
            {
                new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name2_" + DateTime.Now.ToFileTimeUtc() },
                new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName2_" + DateTime.Now.ToFileTimeUtc() }
                //here you can add all the fields you want to add...
            }
        };
        recipients.Add(recipient1);
        recipients.Add(recipient2);
        int subscriptionResult = 0;
        try
        {
            subscriptionResult = client.AddRecipientsToList(idList, recipients, true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }
    
        // 2.1) wait for the end of import task:
        if (subscriptionResult > 0)
        {
            Console.WriteLine("Recipients Import started; import ID:" + subscriptionResult);
    
            //optionally we can check the import status:
            bool completed = false;
            do
            {
                ConsoleImportStatus importStatus = client.CheckImportStatus(subscriptionResult);
                if (importStatus == null)
                {
                    Console.WriteLine("Cannot check the import status for import task #" + subscriptionResult);
                    return;
                }
                completed = importStatus.Completed;
            } while (!completed);
            Console.WriteLine("Recipients Added!");
        }
        else
        {
            Console.WriteLine("An error occurred while adding the recipients.");
            return;
        }
    
        // 3) Retrieve the sendingID of the confirmation email related to the previous task:
        int sendingID = -1;
        try
        {
            sendingID = client.GetSendingIDForImport(subscriptionResult);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot retrieve sending ID due to " + ex.Message);
            return;
        }
        if (sendingID <= 0)
        {
            Console.WriteLine("Cannot retrieve sending ID.");
            return;
        }
    
        // 4) Send the confirmation email:
        EmailSendingItem sendingResult = null;
        try
        {
            sendingResult = client.SendEmailMessage(sendingID);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot send email due to " + ex.Message);
            return;
        }
        if (sendingResult == null)
            Console.WriteLine("Cannot send confirmation email.");
        else
            Console.WriteLine("Confirmation email sent!");
    }
                

    public by ekarakas modified Aug 29, 2013  205611  3  5  0

    Send HTML Emails With PHP

    Send Hassle Free and Dependable HTML Emails With PHP
    function htmlmail($to, $subject, $message, $headers = NULL)
    {
    $mime_boundary = md5(time());
         
    $headers .= "\nMessage-ID: <" . time() . " TheSystem@{$_SERVER['SERVER_NAME']}>\n";
    $headers .= "X-Mailer: PHP " . phpversion() . "\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative;boundary={$mime_boundary}\n\n";
         
    $newmessage = "This is a multi-part message in MIME format.";
    $newmessage .= "\n\n--{$mime_boundary}\n";
    $newmessage .= "Content-type: text/plain;charset=utf-8\n\n";
    $newmessage .= strip_tags(str_replace(array('<br>', '<br />'), "\n", $message)) . "\n\n";
         
    $newmessage .= "\n\n--{$mime_boundary}\n";
    $newmessage .= "Content-type: text/html;charset=utf-8\n\n";
         
    // prepended HTML
    $newmessage .= '<body style="margin:0"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#ffffff" valign="top"><table width="750" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td bgcolor="#ffffff" width="750">';
         
    // HTML message that was passed to this function
    $newmessage .= $message;
         
    // appended HTML
    $newmessage .= '</td></tr></table></td></tr></table></body>';
         
    return mail($to, $subject, $newmessage, $headers);
    }
    

    public by kvasilov48 modified Apr 8, 2015  115872  0  3  0

    Отправка логов ошибок себе на email

    Отправка логов ошибок себе на email: mail.php
    <?php
    
    function nettuts_error_handler($number, $message, $file, $line, $vars){
    	$email = "
    		<p>An error ($number) occurred on line
    		<strong>$line</strong> and in the <strong>file: $file.</strong>
    		<p> $message </p>";
    
    	$email .= "<pre>" . print_r($vars, 1) . "</pre>";
    
    	$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    	// отправка email-а
    	error_log($email, 1, 'you@youremail.com', $headers);
    
    	// останавливаем скрипт при возникновении ошибки
    	// если она не NOTICE.
    	if ( ($number !== E_NOTICE) && ($number < 2048) ) {
    		die("There was an error. Please try again later.");
    	}
    }
    
    // назначаем собственный обработчик.
    set_error_handler('nettuts_error_handler');
    
    // генерируем ошибку... (переменной не существует)
    echo $somevarthatdoesnotexist;
    
    
    

    public by sherazam modified Dec 23, 2015  3067  2  6  0

    How to Manage Attachments in Existing & New Email Messages inside Android Apps

    // Enter here the actual content of the snippet.            //Adding Attachments to a New Email Message
    
    public static void AddAttachmentsToMessage()
    {
    //Base folder
    String  strBaseFolder  = Environment.getExternalStorageDirectory().getPath();
    strBaseFolder = strBaseFolder + "/";
    
    //Create an instance of MailMessage class
    MailMessage message = new MailMessage();
    
    //From
    message.setFrom(new MailAddress("sender@sender.com"));
    
    //To whom
    message.getTo().add(new MailAddress("receiver@gmail.com"));
    
    //Adding 1st attachment
    //Create an instance of Attachment class
    Attachment attachment;
    
    //Load an attachment
    attachment = new Attachment(strBaseFolder + "1.txt");
    
    //Add attachment in instance of MailMessage class
    message.getAttachments().add(attachment);
    
    //Add 2nd Attachment
    message.getAttachments().add(new Attachment(strBaseFolder + "1.jpg"));
    
    //Add 3rd Attachment
    message.getAttachments().add(new Attachment(strBaseFolder + "1.doc"));
    
    //Add 4th Attachment
    message.getAttachments().add(new Attachment(strBaseFolder + "1.rar"));
    
    //Add 5th Attachment
    message.getAttachments().add(new Attachment(strBaseFolder + "1.pdf"));
    
    //Save message to disc
    message.save(strBaseFolder + "output.msg",MessageFormat.getMsg());
    }
    
    //Extracting Attachments from an Existing Email Message
    
    public static void ExtractAttachmentsFromMessage()
    {
        // Base folder for reading and writing files
       String  strBaseFolder  = Environment.getExternalStorageDirectory().getPath();
       strBaseFolder = strBaseFolder + "/";
    
        //Initialize and Load an existing EML file by specifying the MessageFormat
        MailMessage msg = MailMessage.load(strBaseFolder + "AnEmail.eml", MessageFormat.getEml());
    
        //Initialize AttachmentCollection object with MailMessage Attachments
        AttachmentCollection attachments =  msg.getAttachments();
    
        //Iterate over the AttachmentCollection
        for(int index = 0; index < attachments.size(); index++)
        {
            //Initialize Attachment object and Get the indexed Attachment reference
            Attachment attachment = (Attachment) attachments.get(index);
            //Display Attachment Name
            System.out.println(attachment.getName());
            //Save Attachment to disk
            attachment.save(strBaseFolder + "attachment_"+ attachment.getName());
        }
    }
    
    //Adding or Removing Attachments from an Existing Email Message
    
    public static void RemoveAttachmentsFromMessage()
    {
        // Base folder for reading and writing files
        String  strBaseFolder  = Environment.getExternalStorageDirectory().getPath();
        strBaseFolder = strBaseFolder + "/";
    
        //Initialize and Load an existing EML file by specifying the MessageFormat
        MailMessage message = MailMessage.load(strBaseFolder + "AnEmail.eml", MessageFormat.getEml());
    
        //Initialize AttachmentCollection object with MailMessage Attachments
        AttachmentCollection attachments =  message.getAttachments();
        System.out.println("Attachment Count: " + attachments.size());
    
        //Check if AttachmentCollection size is greater than 0
        if(attachments.size() > 0)
        {
            //Remove Attachment from index location 0
            attachments.remove(0);
            System.out.println("Attachment Count: " + attachments.size());
        }
    
        //Add a PDF file as Attachment to the message
        message.addAttachment(new Attachment(strBaseFolder + "Blank.PDF"));
        System.out.println("Attachment Count: " + attachments.size());
    
        //Save the Email message to disk by specifying the EML MailMessageSaveType
        message.save(strBaseFolder + "message.eml", MailMessageSaveType.getEmlFormat());
    }
    
    

    public by sherazam modified Apr 13, 2016  2225  1  2  0

    How to Retrieve Email Messages from Server with Paging Support inside .NET Apps

    This technical tip explains how to .NET developers can list email messages with paging support inside their .NET Applications. In scenarios, where the email server contains a large number of messages in mailbox, it is often desired to list or retrieve the messages with paging support. Aspose.Email API's ImapClient lets you retreive the messages fro
    // Enter here the actual content of the snippet.            
    // Listing Messages with Paging Support
    
    //C# Code Samples
    
    // For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    ///<summary>
    ///This example shows the paging support of ImapClient for listing messages from the server
    ///Available in Aspose.Email for .NET 6.4.0 and onwards
    ///</summary>
    using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password"))
    {
        try
        {
            int messagesNum = 12;
            int itemsPerPage = 5;
            MailMessage message = null;
            //Create some test messages and append these to server's inbox
            for (int i = 0; i < messagesNum; i++)
            {
                message = new MailMessage(
                    "from@domain.com",
                    "to@domain.com",
                    "EMAILNET-35157 - " + Guid.NewGuid().ToString(),
                    "EMAILNET-35157 Move paging parameters to separate class");
                client.AppendMessage(ImapFolderInfo.InBox, message);
            }
    
            //List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox);
            ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages();
            //Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count);
    
            //////////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            List<ImapPageInfo> pages = new List<ImapPageInfo>();
            ImapPageInfo pageInfo = client.ListMessagesByPage(itemsPerPage);
            Console.WriteLine(pageInfo.TotalCount);
            pages.Add(pageInfo);
            while (!pageInfo.LastPage)
            {
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage);
                pages.Add(pageInfo);
            }
            int retrievedItems = 0;
            foreach (ImapPageInfo folderCol in pages)
                retrievedItems += folderCol.Items.Count;
            Console.WriteLine(retrievedItems);
        }
        finally
        {
        }
    }
     
    //VB.NET Code Samples
    
    ' For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    '<summary>
    'This example shows the paging support of ImapClient for listing messages from the server
    'Available in Aspose.Email for .NET 6.4.0 and onwards
    '</summary>
    Using client As New ImapClient("host.domain.com", 993, "username", "password")
        Try
            Dim messagesNum As Integer = 12
            Dim itemsPerPage As Integer = 5
            Dim message As MailMessage = Nothing
            'Create some test messages and append these to server's inbox
            For i As Integer = 0 To messagesNum - 1
                message = New MailMessage("from@domain.com", "to@domain.com", "EMAILNET-35157 - " + Guid.NewGuid().ToString(), "EMAILNET-35157 Move paging parameters to separate class")
                client.AppendMessage(ImapFolderInfo.InBox, message)
            Next
    
            'List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox)
            Dim totalMessageInfoCol As ImapMessageInfoCollection = client.ListMessages()
            'Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count)
    
            '///////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            Dim pages As New List(Of ImapPageInfo)()
            Dim pageInfo As ImapPageInfo = client.ListMessagesByPage(itemsPerPage)
            Console.WriteLine(pageInfo.TotalCount)
            pages.Add(pageInfo)
            While Not pageInfo.LastPage
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage)
                pages.Add(pageInfo)
            End While
            Dim retrievedItems As Integer = 0
            For Each folderCol As ImapPageInfo In pages
                retrievedItems += folderCol.Items.Count
            Next
            Console.WriteLine(retrievedItems)
        Finally
        End Try
    End Using
    

    public by sherazam modified May 11, 2016  2274  0  5  0

    How to Create/Format Forward & Reply Email Messages inside .NET Apps

    This technical tip explains how .NET developers can Create the Forward & Reply Email Messages inside .NET Applications using Aspose.Email for .NET. Aspose.Email API provides the capability of creating and formatting the forward and reply messages. The ReplyMessageBuilder and ForwardMessageBuilder classes of the API are used to create the Reply and
    // Enter here the actual content of the snippet.            
    // Creating Reply Message
    
    //[C# Code Sample]
    
    MapiMessage originalMsg = MapiMessage.FromFile("original.msg");
    
    ReplyMessageBuilder builder = new ReplyMessageBuilder();
    builder.ReplyAll = true;
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
    builder.ResponseText = "<p><b>Dear Friend,</b></p> I want to do is introduce my co-author and co-teacher. <p><a href=\"www.google.com\">This is a first link</a></p><p><a href=\"www.google.com\">This is a second link</a></p>";
    MapiMessage replyMsg = builder.BuildResponse(originalMsg);
    
    replyMsg.Save("reply.msg");
    
    //[VB.NET Code Sample]
    
    Dim originalMsg As MapiMessage = MapiMessage.FromFile("original.msg")
    
    Dim builder As New ReplyMessageBuilder()
    builder.ReplyAll = True
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart
    builder.ResponseText = "<p><b>Dear Friend,</b></p> I want to do is introduce my co-author and co-teacher. <p><a href=""www.google.com"">This is a first link</a></p><p><a href=""www.google.com"">This is a second link</a></p>"
    Dim replyMsg As MapiMessage = builder.BuildResponse(originalMsg)
    
    replyMsg.Save("reply.msg")
    
    //Creating Forward Message
    
    //[C# Code Sample]
    
    ForwardMessageBuilder builder = new ForwardMessageBuilder();
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart;
    MapiMessage forwardMsg = builder.BuildResponse(originalMsg);
    forwardMsg.Save("forward.msg");
    
    //[VB.NET Code Sample]
    
    Dim builder As New ForwardMessageBuilder()
    builder.AdditionMode = OriginalMessageAdditionMode.Textpart
    Dim forwardMsg As MapiMessage = builder.BuildResponse(originalMsg)
    forwardMsg.Save("forward.msg")
    
    

    public by sherazam modified Apr 13, 2016  2001  0  2  0

    How to Retrieve Email Messages from Server with Paging Support inside .NET Apps

    This technical tip explains how to .NET developers can list email messages with paging support inside their .NET Applications. In scenarios, where the email server contains a large number of messages in mailbox, it is often desired to list or retrieve the messages with paging support. Aspose.Email API's ImapClient lets you retreive the messages fro
    // Enter here the actual content of the snippet.            
    // Listing Messages with Paging Support
    
    //C# Code Samples
    
    // For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    ///<summary>
    ///This example shows the paging support of ImapClient for listing messages from the server
    ///Available in Aspose.Email for .NET 6.4.0 and onwards
    ///</summary>
    using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password"))
    {
        try
        {
            int messagesNum = 12;
            int itemsPerPage = 5;
            MailMessage message = null;
            //Create some test messages and append these to server's inbox
            for (int i = 0; i < messagesNum; i++)
            {
                message = new MailMessage(
                    "from@domain.com",
                    "to@domain.com",
                    "EMAILNET-35157 - " + Guid.NewGuid().ToString(),
                    "EMAILNET-35157 Move paging parameters to separate class");
                client.AppendMessage(ImapFolderInfo.InBox, message);
            }
    
            //List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox);
            ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages();
            //Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count);
    
            //////////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            List<ImapPageInfo> pages = new List<ImapPageInfo>();
            ImapPageInfo pageInfo = client.ListMessagesByPage(itemsPerPage);
            Console.WriteLine(pageInfo.TotalCount);
            pages.Add(pageInfo);
            while (!pageInfo.LastPage)
            {
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage);
                pages.Add(pageInfo);
            }
            int retrievedItems = 0;
            foreach (ImapPageInfo folderCol in pages)
                retrievedItems += folderCol.Items.Count;
            Console.WriteLine(retrievedItems);
        }
        finally
        {
        }
    }
     
    //VB.NET Code Samples
    
    ' For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    '<summary>
    'This example shows the paging support of ImapClient for listing messages from the server
    'Available in Aspose.Email for .NET 6.4.0 and onwards
    '</summary>
    Using client As New ImapClient("host.domain.com", 993, "username", "password")
        Try
            Dim messagesNum As Integer = 12
            Dim itemsPerPage As Integer = 5
            Dim message As MailMessage = Nothing
            'Create some test messages and append these to server's inbox
            For i As Integer = 0 To messagesNum - 1
                message = New MailMessage("from@domain.com", "to@domain.com", "EMAILNET-35157 - " + Guid.NewGuid().ToString(), "EMAILNET-35157 Move paging parameters to separate class")
                client.AppendMessage(ImapFolderInfo.InBox, message)
            Next
    
            'List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox)
            Dim totalMessageInfoCol As ImapMessageInfoCollection = client.ListMessages()
            'Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count)
    
            '///////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            Dim pages As New List(Of ImapPageInfo)()
            Dim pageInfo As ImapPageInfo = client.ListMessagesByPage(itemsPerPage)
            Console.WriteLine(pageInfo.TotalCount)
            pages.Add(pageInfo)
            While Not pageInfo.LastPage
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage)
                pages.Add(pageInfo)
            End While
            Dim retrievedItems As Integer = 0
            For Each folderCol As ImapPageInfo In pages
                retrievedItems += folderCol.Items.Count
            Next
            Console.WriteLine(retrievedItems)
        Finally
        End Try
    End Using
    

    public by sherazam modified Apr 13, 2016  2332  0  2  0

    How to Retrieve Email Messages from Server with Paging Support inside .NET Apps

    // Enter here the actual content of the snippet.            
    ;;This technical tip explains how to .NET developers can list email messages with paging support inside their .NET Applications. In scenarios, where the email server contains a large number of messages in mailbox, it is often desired to list or retrieve the messages with paging support. Aspose.Email API's ImapClient lets you retreive the messages from the server with paging support.
    
    // Listing Messages with Paging Support
    
    //C# Code Samples
    
    // For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    ///<summary>
    ///This example shows the paging support of ImapClient for listing messages from the server
    ///Available in Aspose.Email for .NET 6.4.0 and onwards
    ///</summary>
    using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password"))
    {
        try
        {
            int messagesNum = 12;
            int itemsPerPage = 5;
            MailMessage message = null;
            //Create some test messages and append these to server's inbox
            for (int i = 0; i < messagesNum; i++)
            {
                message = new MailMessage(
                    "from@domain.com",
                    "to@domain.com",
                    "EMAILNET-35157 - " + Guid.NewGuid().ToString(),
                    "EMAILNET-35157 Move paging parameters to separate class");
                client.AppendMessage(ImapFolderInfo.InBox, message);
            }
    
            //List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox);
            ImapMessageInfoCollection totalMessageInfoCol = client.ListMessages();
            //Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count);
    
            //////////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            List<ImapPageInfo> pages = new List<ImapPageInfo>();
            ImapPageInfo pageInfo = client.ListMessagesByPage(itemsPerPage);
            Console.WriteLine(pageInfo.TotalCount);
            pages.Add(pageInfo);
            while (!pageInfo.LastPage)
            {
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage);
                pages.Add(pageInfo);
            }
            int retrievedItems = 0;
            foreach (ImapPageInfo folderCol in pages)
                retrievedItems += folderCol.Items.Count;
            Console.WriteLine(retrievedItems);
        }
        finally
        {
        }
    }
     
    //VB.NET Code Samples
    
    ' For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
    '<summary>
    'This example shows the paging support of ImapClient for listing messages from the server
    'Available in Aspose.Email for .NET 6.4.0 and onwards
    '</summary>
    Using client As New ImapClient("host.domain.com", 993, "username", "password")
        Try
            Dim messagesNum As Integer = 12
            Dim itemsPerPage As Integer = 5
            Dim message As MailMessage = Nothing
            'Create some test messages and append these to server's inbox
            For i As Integer = 0 To messagesNum - 1
                message = New MailMessage("from@domain.com", "to@domain.com", "EMAILNET-35157 - " + Guid.NewGuid().ToString(), "EMAILNET-35157 Move paging parameters to separate class")
                client.AppendMessage(ImapFolderInfo.InBox, message)
            Next
    
            'List messages from inbox
            client.SelectFolder(ImapFolderInfo.InBox)
            Dim totalMessageInfoCol As ImapMessageInfoCollection = client.ListMessages()
            'Verify the number of messages added
            Console.WriteLine(totalMessageInfoCol.Count)
    
            '///////////////RETREIVE THE MESSAGES USING PAGING SUPPORT////////////////////////////////////
    
            Dim pages As New List(Of ImapPageInfo)()
            Dim pageInfo As ImapPageInfo = client.ListMessagesByPage(itemsPerPage)
            Console.WriteLine(pageInfo.TotalCount)
            pages.Add(pageInfo)
            While Not pageInfo.LastPage
                pageInfo = client.ListMessagesByPage(pageInfo.NextPage)
                pages.Add(pageInfo)
            End While
            Dim retrievedItems As Integer = 0
            For Each folderCol As ImapPageInfo In pages
                retrievedItems += folderCol.Items.Count
            Next
            Console.WriteLine(retrievedItems)
        Finally
        End Try
    End Using
    
    • Public Snippets
    • Channels Snippets