PowerTCP Mail for .NET
PopMessage Class
Members  Example 




Represents a message the POP server is managing.Represents a message the POP server is managing.
Object Model
PopMessage ClassMailMessage Class
Syntax
Public Class PopMessage 
   Inherits MessageBase
Dim instance As PopMessage
public class PopMessage : MessageBase 
public __gc class PopMessage : public MessageBase 
public ref class PopMessage : public MessageBase 
Remarks

A PopMessage object represents a message on the POP server. Messages existing on the POP server are managed through use of Pop.Messages, a collection of PopMessage objects representing the messages available on the server. On login, this array will contain an empty PopMessage for each message on the server; retrieve just the headers with PopMessage.Get(0) for each PopMessage in the array, or retrieve the entire message with PopMessage.Get().

Once you get a message, access the PopMessage.Message property for the MailMessage object encapsulating the message.

PopMessage objects can only be created internally by the Pop component. A PopMessage object cannot be explicitly created by the user.

Example
In this example, messages are retrieved with the Pop component then saved to disk.
private void getMessages(object sender)
{
    //Connect and log into the account
    pop1.Connect();
    pop1.Authenticate(true, true);

    //Download all messages in the account and save them to disk with a unique name
    string messageFolder = Application.StartupPath + "\\messages";
    foreach (PopMessage popMessage in pop1.Messages)
    {
        popMessage.Get();
        popMessage.Message.Save(messageFolder + "\\" + popMessage.Id.ToString("D4") + ".eml");
    }

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

private void pop1_Progress(object sender, PopProgressEventArgs e)
{
    //Update progress bar as messages are received
    progressBar1.Value = (e.Final) ? 0 : (int)((e.Position * 100) / e.Length);
}
Private Sub getMessages(ByVal sender As Object)
    'Connect and log into the account
    pop1.Connect()
    pop1.Authenticate(True, True)

    'Download all messages in the account and save them to disk with a unique name
    Dim messageFolder As String = Application.StartupPath & "\messages"
    For Each popMessage As PopMessage In pop1.Messages
        popMessage.Get()
        popMessage.Message.Save(messageFolder & "\" & popMessage.Id.ToString("D4") & ".eml")
    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
    'Update progress bar as messages are received
    progressBar1.Value = If(e.Final, 0, CInt((e.Position * 100) \ e.Length))
End Sub
Inheritance Hierarchy

System.Object
   Dart.Mail.MessageBase
      Dart.Mail.PopMessage

See Also

Reference

PopMessage Members
Dart.Mail Namespace


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