PowerTCP Mail for .NET
Close Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Smtp Class : Close Method




Ceases all activity and gracefully closes the control connection.

Syntax

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(); 

Exceptions

ExceptionDescription
Dart.PowerTCP.Mail.ProtocolExceptionBad SMTP 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 closing the Smtp component's connection.
Visual BasicCopy 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();
   }
}

Remarks

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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