PowerTCP Mail for .NET
Connection Property
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Smtp Class : Connection Property




Gets the Tcp component instance used for the connection.

Syntax

Visual Basic (Declaration) 
<BrowsableAttribute(False)>
Public ReadOnly Property Connection As Tcp
Visual Basic (Usage)Copy Code
Dim instance As Smtp
Dim value As Tcp
 
value = instance.Connection
C# 
[BrowsableAttribute(false)]
public Tcp Connection {get;}
Managed Extensions for C++ 
[BrowsableAttribute(false)]
public: __property Tcp* get_Connection();
C++/CLI 
[BrowsableAttribute(false)]
public:
property Tcp^ Connection {
   Tcp^ get();
}

Property Value

The Tcp instance that the PowerTCP component uses for the connection.

Example

The following example demonstrates using the exposed TCP connection to send commands to an SMTP server.
Visual BasicCopy Code
' Connect to the server
Smtp1.Connection.Connect("mail.test.com", 25)

' Receive the response. (Don't have to do anything with it).
Smtp1.Connection.Receive()

' Send EHLO command.
Smtp1.Connection.Send("EHLO myserver" + vbCrLf)

' Recieve the response. (Don't have to do anything with it).
Smtp1.Connection.Receive()

' Get HELP on a command. 
Smtp1.Connection.Send("HELP EHLO" + vbCrLf)

' Receive the response into a string.
Dim s As String = Smtp1.Connection.Receive().ToString()

' Display the response.
Debug.WriteLine(s)

' Send QUIT command.
Smtp1.Connection.Send("QUIT" + vbCrLf)

' Receive the response.
Smtp1.Connection.Receive()
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

// Connect to the server
smtp1.Connection.Connect("mail.test.com", 25);
			
// Receive the response. (Don't have to do anything with it).
smtp1.Connection.Receive();

// Send EHLO command.
smtp1.Connection.Send("EHLO myserver\r\n");

// Recieve the response. (Don't have to do anything with it).
smtp1.Connection.Receive();

// Get HELP on a command. 
smtp1.Connection.Send("HELP EHLO\r\n");

// Receive the response into a string.
string s = smtp1.Connection.Receive().ToString();
			
// Display the response.
Debug.WriteLine(s);

// Send QUIT command.
smtp1.Connection.Send("QUIT\r\n");

// Receive the response.
smtp1.Connection.Receive();

Remarks

Many PowerTCP components use the Tcp component for the connection. This property exposes that object, allowing such actions as sending server requests directly over the TCP connection or getting information about the socket (such as local/remote IP addresses). If you need to communicate with a proxy server, set the properties of Object.Connection.Proxy to enable proxy communication. In addition, Object.Connection.Send can be used to send any command to the server.

Use the Object.Connection property to directly access the TCP connection. This could be useful if:

  • You need to use the Tcp.Proxy object to communicate with proxy servers.
  • You wish to display information about the socket endpoints to the user (local/remote IP addresses, for example).
  • You want to use the Tcp object used by the PowerTCP component as an initializer for the TraceForm.
  • You wish to capture trace information by using the Tcp.Trace event.
  • You wish to close the connection.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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