[C#]
POP3 pop = new POP3( "127.0.0.1", "dave@blah.com", "mypassword"); //if we have write permissions we can log the session pop.LogPath = "c:\\aspNetPOP3.log"; pop.LogOverwrite = true; //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(); Console.WriteLine( "There are {0} messages waiting.", pop.InboxMessageCount ); Console.WriteLine( "The total inbox size is {0} bytes.", pop.InboxSize ); //get a message string text = pop.GetMessageAsText( 1 ); //show the message Console.WriteLine( text ); //Close the POP3 Connection pop.Disconnect(); //display the log Console.WriteLine( "Log----"); Console.WriteLine( pop.Log );
[VB.NET]
Dim pop As New POP3("127.0.0.1", "dave@blah.com", "mypassword") 'if we have write permissions we can log the session pop.LogPath = "c:\aspNetPOP3.log" pop.LogOverwrite = True '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() Console.WriteLine("There are {0} messages waiting.", pop.InboxMessageCount) Console.WriteLine("The total inbox size is {0} bytes.", pop.InboxSize) 'get a message Dim emailText As String = pop.GetMessageAsText(1) 'show the message Console.WriteLine(emailText) 'Close the POP3 Connection pop.Disconnect()
POP3 pop = new POP3( "127.0.0.1", "dave@blah.com", "mypassword"); //if we have write permissions we can log the session pop.LogPath = "c:\\aspNetPOP3.log"; pop.LogOverwrite = true; //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(); Console.WriteLine( "There are {0} messages waiting.", pop.InboxMessageCount ); Console.WriteLine( "The total inbox size is {0} bytes.", pop.InboxSize ); //Close the POP3 Connection pop.Disconnect(); //display the log Console.WriteLine( "Log----"); Console.WriteLine( pop.Log );
[Visual Basic]
POP3 pop = new POP3( "127.0.0.1", "dave@blah.com", "mypassword"); //if we have write permissions we can log the session pop.LogPath = "c:\\aspNetPOP3.log"; pop.LogOverwrite = true; //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(); Console.WriteLine( "There are {0} messages waiting.", pop.InboxMessageCount ); Console.WriteLine( "The total inbox size is {0} bytes.", pop.InboxSize ); //Close the POP3 Connection pop.Disconnect(); //display the log Console.WriteLine( "Log----"); Console.WriteLine( pop.Log );
POP3 pop = new POP3(); //connect to the POP3 server pop.Connect("dave@blah.com", "mypassword","127.0.0.1" ); //get a datatable of headers ArrayList al = pop.HeaderList(); for( int i=0;i<al.Count;i++) { Console.WriteLine("-------------------------------"); Console.WriteLine( al[i].ToString() ); } //Close the POP3 Connection pop.Disconnect();
Dim pop As New POP3() 'connect to the POP3 server pop.Connect("dave@blah.com", "mypassword", "127.0.0.1") 'get a datatable of headers Dim al As ArrayList = pop.HeaderList() Dim i As Integer For i = 0 To al.Count - 1 Console.WriteLine("-------------------------------") Console.WriteLine(al(i).ToString()) Next i 'Close the POP3 Connection pop.Disconnect()
//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 );
'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)
//create a new pop3 object POP3 pop = new POP3("127.0.0.1","dave@blah.com", "mypassword" ); //connect to the POP3 server pop.Connect(); Message msg = pop.GetMessage(1 ); //save attachments to a directory msg.SaveAttachments( "c:\\temp\\mydirectory\\", true ); pop.Disconnect(); //done Console.WriteLine( "done."); Console.ReadLine( );
'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() Dim msg As Message = pop.GetMessage(1) 'save attachments to a directory msg.SaveAttachments("c:\temp\mydirectory\", True) pop.Disconnect() 'done Console.WriteLine("done.") Console.ReadLine()
Copyright 2003 - Contact: Webmaster Last Updated: Tuesday, March 02, 2010