PowerTCP Mail for .NET
Login(String,String,String) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Pop Class > Login Method : Login(String,String,String) Method




server
The POP server to log in to.
username
Username used to log in to the POP server.
password
Password used to log in to the POP server.
Synchronously log in to a POP server and initialize the PopMessage array.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Login( _
   ByVal server As String, _
   ByVal username As String, _
   ByVal password As String _
) 
Visual Basic (Usage)Copy Code
Dim instance As Pop
Dim server As String
Dim username As String
Dim password As String
 
instance.Login(server, username, password)
C# 
public void Login( 
   string server,
   string username,
   string password
)
Managed Extensions for C++ 
public: void Login( 
   string* server,
   string* username,
   string* password
) 
C++/CLI 
public:
void Login( 
   String^ server,
   String^ username,
   String^ password
) 

Parameters

server
The POP server to log in to.
username
Username used to log in to the POP server.
password
Password used to log in to the POP server.

Exceptions

ExceptionDescription
Dart.PowerTCP.Mail.ProtocolExceptionBad POP protocol response received from server.
System.Net.Sockets.SocketExceptionThe requested address is not valid in its context.
System.IO.IOExceptionThe filename, directory name, or volume label syntax is incorrect.
System.ArgumentExceptionA required argument contains invalid characters, is empty, or contains only white spaces.

Example

The following example demonstrates logging into a POP server and retrieving all messages.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

' Automatically remove files after getting them from the server
Pop1.AutoDelete = True

' Login. The default settings will cause the Pop component to
' automatically retrieve all messages, delete them from the
' server, and logout.
Pop1.Login("mail.test.com", "testuser", "testpass")

' All message retrieved. Iterate through the collection
' and display data.
Dim msg As PopMessage
For Each msg In Pop1.Messages
   Debug.WriteLine("Message ID: " + msg.Id)
   Debug.WriteLine("Message UID: " + msg.Uid)
   Debug.WriteLine("Messge Size: " + msg.Size)
   Debug.WriteLine("From: " + msg.Message.From.Address)
   Debug.WriteLine("Subject: " + msg.Message.Subject)
Next
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

// Automatically remove files after getting them from the server
pop1.AutoDelete = true;

// Login. The default settings will cause the Pop component to
// automatically retrieve all messages, delete them from the
// server, and logout.
pop1.Login("mail.test.com", "testuser", "testpass");

// All message retrieved. Iterate through the collection
// and display data.
foreach(PopMessage msg in pop1.Messages)
{
   Debug.WriteLine("Message ID: " + msg.Id);
   Debug.WriteLine("Message UID: " + msg.Uid);
   Debug.WriteLine("Messge Size: " + msg.Size);
   Debug.WriteLine("From: " + msg.Message.From.Address);
   Debug.WriteLine("Subject: " + msg.Message.Subject);
}

Remarks

This method represents the quickest and easiest means of logging in to a POP server. Upon logging in, the Pop.Message property will be populated with the new messages available on the POP server. The Pop component can be configured to populate the Pop.Message property with message data in one of three ways upon login:

  • If Pop.AutoGet = MessageSection.None the Pop.Messages collection will be populated with MessageStream objects containing the minimal data returned from the server about the message (id, unique id, and size of the message).
  • If Pop.AutoGet = MessageSection.Complete then the Pop.Messages collection will be populated with MessageStream objects containing the full message.
  • If Pop.AutoGet = MessageSection.Header then the Pop.Messages collection will be populated with MessageStream objects containing only the header.
The Pop component will remain logged in until the Pop.Logout method is called. This method will attempt to automatically log in to port 110, the well-known port for POP. If you need to login to a port that is NOT port 110, use the Pop.Login(String,Int32,String,Int32,String,String) method.

To log in to the POP server asynchronously, use Pop.BeginLogin.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.