| Visual Basic (Declaration) | |
|---|---|
Public Sub Close() | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Smtp instance.Close() | |
| C# | |
|---|---|
public void Close() | |
| Managed Extensions for C++ | |
|---|---|
public: void Close(); | |
| C++/CLI | |
|---|---|
public: void Close(); | |
| Exception | Description |
|---|---|
| Dart.PowerTCP.Mail.ProtocolException | Bad SMTP protocol response received from server. |
| System.Net.Sockets.SocketException | The requested address is not valid in its context. |
| System.IO.IOException | The filename, directory name, or volume label syntax is incorrect. |
| System.ArgumentException | A required argument contains invalid characters, is empty, or contains only white spaces. |
The following example demonstrates closing the Smtp component's connection.
| Visual Basic | Copy Code |
|---|---|
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail" ' at the top of your class. ' First check if the Smtp component is connected If Smtp1.Connected Then Try ' Try to close gracefully Smtp1.Close() Catch ex As Exception ' If an error occurs here, just abruptly close. Smtp1.Dispose() End Try End If | |
| C# | Copy Code |
|---|---|
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;" // at the top of your class. // First check if the Smtp component is connected if(smtp1.Connected) { try { // Try to close gracefully smtp1.Close(); } catch(Exception ex) { // If an error occurs here, just abruptly close. smtp1.Dispose(); } } | |
This method causes a "QUIT" command to be issued to the server. This method sends a QUIT command and waits until the server has closed the connection.
Use this method to terminate the connection. This method should be considered the intended means of ending an SMTP session. It differs from the Smtp.Dispose method in that the Smtp.Dispose method is used to abruptly close the connection and release all resources associated with the Smtp component.
Target Platforms: Microsoft .NET Framework 2.0