Il seguente esempio mostra la possibilità di leggere i messaggi di posta elettronica di un account POP3 e di scaricare gli eventuali allegati. La procedura utilizza la libreria LumiSoft

Imports LumiSoft.Net.Log
Imports LumiSoft.Net.MIME
Imports LumiSoft.Net.Mail
Imports LumiSoft.Net.POP3.Client

Partial Class MyPOP3
    Inherits System.Web.UI.Page

	Protected Sub ReadMessage()
        Dim pop3 As POP3_Client = New POP3_Client
        Try
            pop3.Logger = New Logger
            pop3.Connect("pop3_server", 110, False)
            pop3.Authenticate("username", "password", True)
            Dim i As Integer = 0
            For Each message As POP3_ClientMessage In pop3.Messages
                If Not message.IsMarkedForDeletion Then
                    Dim mime As Mail_Message = Mail_Message.ParseFromByte(message.HeaderToByte)
                    Dim mId As String = message.SequenceNumber.ToString()
                    Dim mUid As String = message.UID
                    Dim mDate As String = mime.Date.ToString
					
					'Email del mittente
                    Dim mEmail As String = String.Empty
                    If Not mime.From Is Nothing Then mEmail = mime.From.Item(0).Address Else mEmail = "" End If
					
					'Nome del mittente
                    Dim mFrom As String = String.Empty
                    If Not mime.From Is Nothing Then mFrom = mime.From.Item(0).DisplayName Else mFrom = "" End If
					
					'Oggetto
                    Dim mSubj As String = String.Empty
                    If Not mime.Subject Is Nothing Then mSubj = mime.Subject.ToString Else mSubj = "" End If
					
					'Testo del messaggio
                    Dim mimeMsg As Mail_Message = Mail_Message.ParseFromByte(message.MessageToByte)
                    Dim mText As String = String.Empty
                    If Not mimeMsg.BodyText Is Nothing Then mText = mimeMsg.BodyText Else mText = "" End If
					
					'Gestione allegati: se esiste un allegato, verrà scaricato nella cartella C:\Files
                    Dim mFile As String = String.Empty
                    For Each entity As MIME_Entity In mimeMsg.Attachments
                        If Not entity.ContentDisposition Is Nothing Then
                            Dim f As MIME_h_ContentDisposition = entity.ContentDisposition
                            If Not f.Param_FileName Is Nothing Then
                                mFile = "C:\Files\" & f.Param_FileName
                                Dim ms As MIME_b_SinglepartBase = entity.Body
                                File.WriteAllBytes(mFile, ms.Data)
                            End If
                        End If
                    Next
					
					'Marcatura del messaggio per la cancellazione
					message.MarkForDeletion()
					
					Dim sOut As String = "Messaggio da: " & mFrom & " (" & mEmail & ")<br />"
					sOut &= "Oggetto: " & mSubj & "<br />"
					sOut &= "Testo del messaggio: " & mText & "<hr>"
					Response.Write(sOut)
                End If
            Next
            pop3.Disconnect()
        Catch ex As Exception
            response.Write("<hr>" & ex.Source & "<hr>" & ex.Message & "<hr>" & ex.StackTrace)
        End Try
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ReadMessage()
    End Sub

End Class