aspNetPop3 Sample Code

The following code example assumes that you are using the @import directive to reference the component from the GAC.  You You can avoid this by simply downloading the trial version of the component and placing it in your /bin folder.

Online Documentation for aspNetEmail can be found at: http://www.aspnetpop3.com/documentation.aspx

C# Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetPOP3, Version=2.5.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ Import Namespace="aspNetPOP3"%>

<Script runat="server" Language="C#">

    void Page_Load(object sender, System.EventArgs e)
    {
 
            POP3 pop = new POP3("mail.yourdomain.com", "xyz@yourdomain.com", "mypassword");
           
            //if we don't have write permissions (as in an ASP.NET application, we can maintain the log in memory)
            pop.LogInMemory = true;
           
            //connect to the POP3 server
            pop.Connect();
           
            //get the number of messages and the size of the inbox
            pop.PopulateInboxStats();
           
            Response.Write( "There are {0} messages waiting.", pop.InboxMessageCount );
            Response.Write( "The total inbox size is {0} bytes.", pop.InboxSize );
           
            //get the first message
            string text = pop.GetMessageAsText( 0 );
           
            //show the message
            Response.Write( text );
           
            //Close the POP3 Connection
            pop.Disconnect();
          

    }

</script>

 

VB.NET Sample

// NOTE: The line below can be excluded if you reference the assembly in your web.config. See Related Articles
<%@ Assembly name="aspNetPOP3, Version=2.5.2.0, Culture=neutral, PublicKeyToken=bc571e8da1c1f543" %>

<%@ Import Namespace="aspNetPOP3"%>

<Script runat="server" Language="VB">

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

             Dim pop As New POP3("mail.yourdomain.com", "xyz@yourdomain.com", "mypassword")
           
           
             'if we don't have write permissions (as in an ASP.NET application, we can maintain the log in memory)
             pop.LogInMemory = True
           
             'connect to the POP3 server
             pop.Connect()
           
             'get the number of messages and the size of the inbox
             pop.PopulateInboxStats()
           
             Response.Write("There are {0} messages waiting.", pop.InboxMessageCount)
             Response.Write("The total inbox size is {0} bytes.", pop.InboxSize)
           
             'get the first message
             Dim emailText As String = pop.GetMessageAsText(0)
           
             'show the message
             Response.Write(emailText)
           
              'Close the POP3 Connection
              pop.Disconnect()

    End Sub

</script>