PowerTCP Mail for .NET
Progress Event (Pop)
Example 




Raised repeatedly while an email message is retrieved.
Syntax
Public Event Progress As EventHandler(Of PopProgressEventArgs)
Dim instance As Pop
Dim handler As EventHandler(Of PopProgressEventArgs)
 
AddHandler instance.Progress, handler
public event EventHandler<PopProgressEventArgs> Progress
public: __event EventHandler<PopProgressEventArgs*>* Progress
public:
event EventHandler<PopProgressEventArgs^>^ Progress
Event Data

The event handler receives an argument of type PopProgressEventArgs containing data related to this event. The following PopProgressEventArgs properties provide information specific to this event.

PropertyDescription
Final Returns true the last time a Progress event is raised for a given message. (Inherited from Dart.Mail.ProgressEventArgs)
Length The length of the message data. (Inherited from Dart.Mail.ProgressEventArgs)
MessageGets the PopMessage representing the message currently being retrieved.  
Position The position within the message data. (Inherited from Dart.Mail.ProgressEventArgs)
Remarks

When a message is retrieved Progress is raised as each data buffer is processed. It contains PopProgressEventArgs, providing data useful for displaying progress to the user. For example, if you wish to display progress for the retrieval of ALL messages using a ProgressBar, use 0 for System.Windows.Forms.ProgressBar.Minimum, pop1.Messages.Length for System.Windows.Forms.ProgressBar.Maximum, and MessageBase.Id as System.Windows.Forms.ProgressBar.Value. If you wish to display progress for each message, use 0 for System.Windows.Forms.ProgressBar.Minimum, ProgressEventArgs.Length for System.Windows.Forms.ProgressBar.Maximum, and ProgressEventArgs.Position for System.Windows.Forms.ProgressBar.Value.

ProgressEventArgs.Length uses MessageBase.Size, so the 'getSizes' parameter of Authenticate must be true if a valid length is desired.

Set ComponentBase.SynchronizingObject to enable marshaling of this event to the UI thread.

Example
In this example, the Pop component gets only message headers, and adds the sender, subject and date to a list.
private void previewMessages(object sender)
{
    //Configure server and account info
    pop1.Session.RemoteEndPoint = new Dart.Mail.IPEndPoint(myServer, Pop.GetDefaultPort(pop1.Session));
    pop1.Session.Username = myUsername;
    pop1.Session.Password = myPassword;

    //Connect and log into the account
    pop1.Connect();
    pop1.Authenticate(true, true);

    //Get header fields for each message in the account
    foreach (PopMessage popMessage in pop1.Messages)
        popMessage.Get(0);

    //Gracefully logout of the session
    pop1.Close();
}

private void pop1_Progress(object sender, PopProgressEventArgs e)
{
    //Display message header info in a listview
    if (e.Final)
    {
        string[] header = { e.Message.Message.From, e.Message.Message.Subject, e.Message.Message.Date.ToString() };
        listView1.Items.Add(new ListViewItem(header));
    }
}
Private Sub previewMessages(ByVal sender As Object)
    'Configure server and account info
    pop1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Pop.GetDefaultPort(pop1.Session))
    pop1.Session.Username = myUsername
    pop1.Session.Password = myPassword

    'Connect and log into the account
    pop1.Connect()
    pop1.Authenticate(True, True)

    'Get header fields for each message in the account
    For Each popMessage As PopMessage In pop1.Messages
        popMessage.Get(0)
    Next popMessage

    'Gracefully logout of the session
    pop1.Close()
End Sub

Private Sub pop1_Progress(ByVal sender As Object, ByVal e As PopProgressEventArgs) Handles pop1.Progress
    'Display message header info in a listview
    If e.Final Then
        Dim header() As String = { e.Message.Message.From, e.Message.Message.Subject, e.Message.Message.Date.ToString() }
        listView1.Items.Add(New ListViewItem(header))
    End If
End Sub
See Also

Reference

Pop Class
Pop Members


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic