SmtpClient Class

Allows applications to send messages by using the Simple Mail Transfer Protocol (SMTP).
Inheritance Hierarchy

Namespace:  Aspose.Email.Clients.Smtp
Assembly:  Aspose.Email (in Aspose.Email.dll) Version: 20.2
Syntax
public sealed class SmtpClient : CredentialsByHostClient, 
	IMailTransferAgent, IDisposable

The SmtpClient type exposes the following members.

Constructors
  NameDescription
Public methodSmtpClient
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(Configuration)
Initializes a new instance of the SmtpClient class by using configuration file settings.
Public methodSmtpClient(String)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, ITokenProvider)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, String)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, ITokenProvider)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, String)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, ITokenProvider, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, String, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, String, Boolean)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, ITokenProvider, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, String, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, String, Boolean)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, String, String, Boolean, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Public methodSmtpClient(String, Int32, String, String, Boolean, SecurityOptions)
Initializes a new instance of the SmtpClient class.
Properties
  NameDescription
Public propertyAccessToken
Gets or sets the access token.
(Inherited from EmailClient.)
Public propertyClientCertificates
Contains collection of clients certificates
(Inherited from EmailClient.)
Public propertyConnectionAsgmtMode
Gets or sets value which defines mode of connection allocation in multiple threads environment There are folowing connection types: - Main connection is connection created and disposed together with mail client.It can't be created or disposed manually. - Default connection is connection default for some thread. If default connection exists and ConnectionAsgmtMode allow, all methods of email client executed in this thread will be implicitly use this connection. Only one default connection can be exist per thread. It can be created manually or automatically. It depends on EmailClient.ConnectionAsgmtMode property. These connections can be created manually with EmailClient.CreateConnection(createAsDefaultConnection = true) method. If default connection does not used(depends on connection allocation mode), main connection used implicitly instead of it. - Independent connections are connections that are not linked to threads.They can be created manually and has to be used explicitly as method parameter. These connections can be created manually with EmailClient.CreateConnection() method or EmailClient.CreateConnection(createAsDefaultConnection = false) method. There are folowing connection allocation types: - ConnectionAsgmtType.UseMainOrDefault This mode uses by default in email clients. Email client uses main connection for all operations from multiple threads if default connection hasn't been created, or connection hasnt been passed as method parameter explicitly. Main connection is connection which is created in the same time like email client. User can create default connections for threads with CreateConnection method. If default connection for thread is created, it's used implicitly for all methods of email client which are invoked in this thread. If default connection for thread is not created, main connection is used for all methods of email client which are invoked in this thread. User also can create connections not linked with threads (not default connections) with CreateConnection method. If user wants to use other connections (not main and not default) he has to pass this connection explicitly as parameter of a method which he wants to use. User can additionally create any number of connections. Default connection can be only one per thread. Please note default connections works correctly if user uses Thread objects for multitasking programming. If user uses ConnectionPool or uses Task objects for multitasking programming this mode may lead to wrong behaviour of a programm. To avoid this problem user has to manually dispose default conection (if he uses it) in the end of the code which executes in the thread. - ConnectionAsgmtType.UseMain Email client uses main connection for all operations from multiple threads. Main connection is connection which is created in the same time like email client. User cann't create default connections. User can create connections not linked with threads (not default connections) with CreateConnection method. If user wants to use other connections (not main and not default) he has to pass this connection explicitly as parameter of a method which he wants to use. User can additionally create any number of connections. - ConnectionAsgmtType.UseDefault Email client uses implicitly only default connections for all operations from multiple threads. Main connection is not used in this mode. If default connection hasn't been created for some thread (first invocation of email client method), email client creates default connection implicitly for thread before first operation is executed. User can't create default connections for threads with CreateConnection method because they are created automatically. When default connection for thread is created, it's used implicitly for all methods of email client which are invoked in this thread.read. User also can create connections not linked with threads (not default connections) with CreateConnection method. If user wants to use other connections (not main and not default) he has to pass this connection explicitly as parameter of a method which he wants to use. User can additionally create any number of connections. Default connection can be only one per thread. Please note default connections works correctly if user uses Thread objects for multitasking programming. If user uses ConnectionPool or uses Task objects for multitasking programming this mode may lead to wrong behaviour of a programm. To avoid this problem user has to manually dispose default conection in the end of the code which executes in the thread.
(Inherited from EmailClient.)
Public propertyConnectionCheckupPeriod
Period of connection checking up in milliseconds. Default value is 5 min.
(Inherited from EmailClient.)
Public propertyConnectionsQuantity
Gets or sets quantity of connections in multy-connection mode
(Inherited from EmailClient.)
Public propertyConnectionState
Gets the current state of the connection.
(Inherited from EmailClient.)
Public propertyCurrentConnection
Gets current connection according to ConnectionAsgmtMode option
(Inherited from EmailClient.)
Public propertyDefaultPort
Gets default port for client
(Overrides EmailClientDefaultPort.)
Public propertyDeliveryMethod
Gets or sets the delivery method.
Public propertyEnableLogger
Gets or sets value which allows enable/disable logger
(Inherited from EmailClient.)
Public propertyEncoding Obsolete.
Gets or sets the encoding.
Public propertyHelloMessage
Gets or sets a HELO/EHLO string.
Public propertyHost
Gets or sets the host name.
(Inherited from EmailClient.)
Public propertyLogFileName
Gets or sets log file name
(Inherited from EmailClient.)
Public propertyPassword
Gets or sets the password.
(Inherited from EmailClient.)
Public propertyPickupDirectoryLocation
Gets or sets the directory where applications save mail messages to be processed by the local SMTP server. Please note: only absolute path is allowed.
Public propertyPort
Gets or sets the port.
(Inherited from EmailClient.)
Public propertyProxy
Gets or sets proxy for the client
(Inherited from EmailClient.)
Public propertySecurityOptions
Security mode for a mail client
(Inherited from EmailClient.)
Public propertySmtpQueueLocation
Gets or sets the directory where applications save mail messages to be processed by sending in SMTP queue. Please note: only absolute path is allowed.
Public propertySupportedEncryption
Defines the versions of SSL/TLS encription protocols to be uised.
(Inherited from EmailClient.)
Public propertyTimeout
Gets or sets the timeout for mail operations
(Inherited from EmailClient.)
Public propertyTokenProvider
Gets or sets TokenProvider allowing to retrieve access token.
(Inherited from EmailClient.)
Public propertyUseAuthentication
Indicates whether authentication is used.
(Inherited from EmailClient.)
Public propertyUseDateInLogFileName
Gets or sets value which indicates if date has to be used in log file name.
(Inherited from EmailClient.)
Public propertyUseDefaultCredentials
Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.
(Overrides EmailClientUseDefaultCredentials.)
Public propertyUseMultiConnection
Gets or sets value which indicates if client has to use multiple connections for heavy loaded operations. Please note, using of this mode not necessary has to lead to performance increasing.
(Inherited from EmailClient.)
Public propertyUseMultyConnection Obsolete.
Gets or sets value which indicates if client has to use multiple connections for heavy loaded operations. Please note, using of this mode not necessary has to lead to performance increasing.
(Inherited from EmailClient.)
Public propertyUsePipelining
Gets or sets object which indicates whether the pipelining mode is enabled.
(Inherited from EmailClient.)
Public propertyUsername
Gets or sets the username.
(Inherited from EmailClient.)
Public propertyUseTnef
Gets or sets a boolean value that controls whether the messages are sent in TNEF format. Note, that now message is sent in TNEF format when being loaded a message contains tnef.
Methods
  NameDescription
Public methodBeginForward(String, MailAddressCollection, MailMessage)
Begins forward email asynchronously.
Public methodBeginForward(String, String, MailMessage)
Begins forward email asynchronously.
Public methodBeginForward(String, MailAddressCollection, MailMessage, AsyncCallback)
Begins forward email asynchronously.
Public methodBeginForward(String, String, MailMessage, AsyncCallback)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, MailAddressCollection, MailMessage)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, String, MailMessage)
Begins forward email asynchronously.
Public methodBeginForward(String, MailAddressCollection, MailMessage, AsyncCallback, Object)
Begins forward email asynchronously.
Public methodBeginForward(String, String, MailMessage, AsyncCallback, Object)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, MailAddressCollection, MailMessage, AsyncCallback)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, String, MailMessage, AsyncCallback)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, MailAddressCollection, MailMessage, AsyncCallback, Object)
Begins forward email asynchronously.
Public methodBeginForward(IConnection, String, String, MailMessage, AsyncCallback, Object)
Begins forward email asynchronously.
Public methodBeginNoop
Begins to execute 'No operation' command
Public methodBeginNoop(AsyncCallback)
Begins to execute 'No operation' command
Public methodBeginNoop(IConnection)
Begins to execute 'No operation' command
Public methodBeginNoop(AsyncCallback, Object)
Begins to execute 'No operation' command
Public methodBeginNoop(IConnection, AsyncCallback)
Begins to execute 'No operation' command
Public methodBeginNoop(IConnection, AsyncCallback, Object)
Begins to execute 'No operation' command
Public methodBeginSend(MailMessage)
Begins sending email asynchronously.
Public methodBeginSend(MailMessage)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, MailMessage)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, MailMessage)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage)
Begins sending email asynchronously.
Public methodBeginSend(MailMessage, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage, EventHandlerMailMessageEventArgs)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, MailMessage, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage, EventHandlerMailMessageEventArgs)
Begins sending email asynchronously.
Public methodBeginSend(MailMessage, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage, EventHandlerMailMessageEventArgs, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(String, String, String, String)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, MailMessage, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage, EventHandlerMailMessageEventArgs, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IEnumerableMailMessage, EventHandlerMailMessageEventArgs, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(String, String, String, String, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, IEnumerableMailMessage, EventHandlerMailMessageEventArgs, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, String, String, String, String)
Begins sending email asynchronously.
Public methodBeginSend(String, String, String, String, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, String, String, String, String, AsyncCallback)
Begins sending email asynchronously.
Public methodBeginSend(IConnection, String, String, String, String, AsyncCallback, Object)
Begins sending email asynchronously.
Public methodBeginSendQueue
Begins to execute 'No operation' command
Public methodBeginSendQueue(AsyncCallback)
Begins to execute 'No operation' command
Public methodBeginSendQueue(AsyncCallback, Object)
Begins to execute 'No operation' command
Public methodCancelAsyncOperation
Cancels asynchronous operation.
(Inherited from EmailClient.)
Public methodCreateConnection
Creates new independent connection for operations not linked to threads (not default connection). Invocation of this method is similar to invocation of CreateConnection(createAsDefaultConnection = false) Please see more in documentation for EmailClient.ConnectionAsgmtMode property.
(Inherited from EmailClient.)
Public methodCreateConnection(Boolean)
Creates new (default or independent) connection for operations. Please see more in documentation for EmailClient.ConnectionAsgmtMode property.
(Inherited from EmailClient.)
Public methodDispose
Finalizes all operations with a server.
(Inherited from EmailClient.)
Public methodEndBeginSendQueue
Waits for the pending asynchronous operation to complete.
Public methodEndForward
Waits for the asynchronous operation to complete.
Public methodEndNoop
Waits for the pending asynchronous operation to complete.
Public methodEndSend
Waits for the asynchronous operation to complete.
Public methodEquals (Inherited from Object.)
Public methodForward(String, MailAddressCollection, MailMessage)
Forwards specified message to recipient
Public methodForward(String, MailAddressCollection, Stream)
Forwards specified message to recipient
Public methodForward(String, String, MailMessage)
Forwards specified message to recipient
Public methodForward(IConnection, String, MailAddressCollection, MailMessage)
Forwards specified message to recipient
Public methodForward(IConnection, String, MailAddressCollection, Stream)
Forwards specified message to recipient
Public methodForward(IConnection, String, String, MailMessage)
Forwards specified message to recipient
Public methodGetCapabilities (Inherited from EmailClient.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodNoop
'No operation' command
(Overrides EmailClientNoop.)
Public methodNoop(IConnection)
'No operation' command
(Overrides EmailClientNoop(IConnection).)
Public methodResetLogSettings
Resets logging settings to default.
(Inherited from EmailClient.)
Public methodSend(MailMessage)
Send the specified message.
Public methodSend(MailMessage)
Send the specified message.
Public methodSend(IEnumerableMailMessage)
Send the specified messages.
Public methodSend(MailMessageCollection)
Send the specified message collection.
Public methodSend(IConnection, MailMessage)
Send the specified message.
Public methodSend(IConnection, MailMessage)
Send the specified message.
Public methodSend(IConnection, MailMessageCollection)
Send the specified message collection.
Public methodSend(IConnection, IEnumerableMailMessage)
Send the specified messages.
Public methodSend(String, String, String, String)
Creates and sends the specified message.
Public methodSend(IConnection, String, String, String, String)
Creates and sends the specified message.
Public methodSendToQueue
Append messages to queue
Public methodToString (Inherited from Object.)
Events
  NameDescription
Public eventBindIPEndPoint
Associates a Socket with a local endpoint.
(Inherited from EmailClient.)
Public eventFailedQueueSending
Adds or removes subscriber for notifications about failed sending operations in smtp queue
Public eventOnConnect
The OnConnect event occurs when the clent establishes connection.
(Inherited from EmailClient.)
Public eventSucceededQueueSending
Adds or removes subscriber for notifications about succeeded sending operations in smtp queue
See Also