Dart.Mail Namespace : Pop Class |
Flexible POP message support provides easy retrieval of messages. Features include multiple authentication techniques, downloading into a user-specified Stream, proxy support and the ability to send commands.
A short description of common usage follows. See the "Code Examples" topic for examples in C# and VB.
Easy session management: Authenticate connects and authenticates to the server, and populates Messages with information about the messages present in the mail drop. The session should be explicitly closed using Close.
Message retrieval: Use Pop.Messages[n].Get() to retrieve any message. Messages can be retrieved into a MailMessage.GetEncodingStream() object (for automatic decoding) or into any other user-specified Stream (for saving the encoded message).
"On-the-fly" decoding: Parts are decoded "on the fly" and streamed to memory or disk (for file attachments), minimizing the memory footprint.
Displaying Progress: Progress provides real-time notification of the number of bytes received while downloading.
Viewing POP Protocol Communication: The Pop.Connection.Log event provides access to all commands and data sent over the TCP connection.
Control connection: Connection exposes the TCP connection, allowing access to low-level properties and methods. This can be used to view TCP-level properties, such as the local and remote IP address.
Sending commands: Any command (including proprietary commands) can be sent/received using Connection.Write() and Connection.Read().
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
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Dart.Mail.ComponentBase
Dart.Mail.MailBase
Dart.Mail.Pop