PowerTCP Mail for .NET
Get(Stream,Int32) Method
Example 




Stream to be written to.
Number of body lines requested from server. -1 is used to indicate the entire message. 0 gets the header only.
Gets the specified number of body lines of an encoded message from the server and writes it to the provided Stream. The header is always included.
Syntax
Public Overloads Sub Get( _
   ByVal destination As Stream, _
   ByVal bodyLines As Integer _
) 
Dim instance As PopMessage
Dim destination As Stream
Dim bodyLines As Integer
 
instance.Get(destination, bodyLines)
public void Get( 
   Stream destination,
   int bodyLines
)
public: void Get( 
   Stream* destination,
   int bodyLines
) 
public:
void Get( 
   Stream^ destination,
   int bodyLines
) 

Parameters

destination
Stream to be written to.
bodyLines
Number of body lines requested from server. -1 is used to indicate the entire message. 0 gets the header only.
Remarks

This method gets a partial message. Part.GetEncodingStream is typically used as the destination Stream for on-the-fly decoding, but storage streams can be used to store the message without decoding it.

This method will set Info as applicable for the value of bodyLines.

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

PopMessage Class
PopMessage Members
Overload List


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