Namespace: System.Net.Mail
SmtpClient
Allows applications to send email by using the Simple Mail Transfer Protocol (SMTP).
Properties (4)
String Host
Gets or sets the name or IP address of the host used for SMTP transactions.
Value: A String that contains the name or IP address of the computer to use for SMTP transactions.
int Port
Gets or sets the port used for SMTP transactions.
Value: An Int32 that contains the port number on the SMTP host. The default value is 25.
int Timeout
Gets or sets a value that specifies the amount of time after which a synchronous Send call times out.
Value: An Int32 that specifies the time-out value in milliseconds. The default value is 100,000 (100 seconds).
bool EnableSsl
Specify whether the SmtpClient uses Secure Sockets Layer (SSL) to encrypt the connection.
Value: true if the SmtpClient uses SSL; otherwise, false. The default is false.
Methods (5)
SmtpClient(String)Constructor
Initializes a new instance of the SmtpClient class that sends email by using the specified SMTP server.
| Parameter | Description |
|---|---|
| host | A String that contains the name or IP address of the host computer used for SMTP transactions. |
SmtpClient(String,Int32)Constructor
Initializes a new instance of the SmtpClient class that sends email by using the specified SMTP server and port.
| Parameter | Description |
|---|---|
| host | A String that contains the name or IP address of the host used for SMTP transactions. |
| port | An Int32 greater than zero that contains the port to be used on host. |
void Send(Net.Mail.MailMessage)
Sends the specified message to an SMTP server for delivery.
| Parameter | Description |
|---|---|
| message | A MailMessage that contains the message to send. |
void Send(String,String,String,String)
Sends the specified email message to an SMTP server for delivery. The message sender, recipients, subject, and message body are specified using String objects.
| Parameter | Description |
|---|---|
| from | A String that contains the address information of the message sender. |
| recipients | A String that contains the addresses that the message is sent to. |
| subject | A String that contains the subject line for the message. |
| body | A String that contains the message body. |
void SendAsync(Net.Mail.MailMessage,Object)
Sends the specified email message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
| Parameter | Description |
|---|---|
| message | A MailMessage that contains the message to send. |
| userToken | A user-defined object that is passed to the method invoked when the asynchronous operation completes. |