Home | Contact Us | Download | Support | Purchase | Shopping Cart | Products


Product List
  "Last year I bought components from both you and from [xxx]. [xxx]'s support is horrendous, to say the least (you have to hate it when you, as a customer, clearly know more about the product than their support personnel). Good work on your frighteningly prompt support."
Fraser T.
 
More
Testimonials

Download Messages' Headers into a DataTable

The following example demonstrates downloading messages 3 - 5 as a DataTable.  It then binds the DataTable to a DataGrid to be displayed in an ASP.NET Web Page.

 

The DataTable contains the following columns:

  1. Int32 MessageNumber -- The message number as found at the POP3 server.

  2. String Headers -- All of the headers

  3. String FromName -- The 'Name' part of the FROM header

  4. String FromAddress -- the 'Address' part of the FROM header

  5. String To -- The 'To' address header

  6. String CC -- The 'CC' address header

  7. String Subject -- The 'Subject' address header

  8. String Date -- The 'Date' address header

  9. String ContentType -- The 'type/subtype' of the Content-Type header

 



[C#]

            //create a new pop3 object
            POP3 pop = new POP3("127.0.0.1","dave@blah.com", "mypassword" );
            
            //connect to the POP3 server
            pop.Connect();
                        
            //download the headers for messages 3 - 5 (inclusive)
            DataTable dt = pop.HeaderTable(3, 5);
            
            
            //Close the POP3 Connection
            pop.Disconnect();
            
            
            //html encode the cells
            for( int r=0;r<dt.Rows.Count;r++)
            {
            	//skip the first col because it's an Int32
            	for( int c=1;c<dt.Columns.Count;c++)
            	{
            		string cellValue = dt.Rows[r][c].ToString();
            		dt.Rows[r][c] = "<pre>" + Server.HtmlEncode( cellValue ) + "</pre>";
            	}
            }
            
            //display the datagrid in ASP.NET page
            DataGrid dg = new DataGrid();
            dg.DataSource = dt;
            dg.DataBind();
            Page.Controls.Add( dg );
            

 

[VB.NET]

 
            'create a new pop3 object
            Dim pop As New POP3("127.0.0.1", "dave@blah.com", "mypassword")
            
            'connect to the POP3 server
            pop.Connect()
            
            'get the messages 3-5 (includes message 3,4, and 5 ) as a DataTable            
            Dim dtMsg As DataTable = pop.MessageTable(3, 5)
            
            'Close the POP3 Connection
            pop.Disconnect()
            
            
            'html encode the cells
            Dim r As Integer
            For r = 0 To dtMsg.Rows.Count - 1
                'skip the first col because it's an Int32
                Dim c As Integer
                For c = 1 To dtMsg.Columns.Count - 1
                    Dim cellValue As String = dtMsg.Rows(r)(c).ToString()
                    dtMsg.Rows(r)(c) = "<pre>" + Server.HtmlEncode(cellValue) + "</pre>"
                Next c
            Next r
            
            'display the  DataTable in a DataGrid in an ASP.NET page
            Dim dgMsg As New DataGrid()
            dgMsg.DataSource = dtMsg
            dgMsg.DataBind()
            Page.Controls.Add(dgMsg)
            



 

 

 



The box is not shipped. aspNetPOP3 is a downloadable product.