VB.Net – Send Email

vb.net allows you to send email from your application. The system.net.mail namespace contains classes used to send email to a Simple Mail Transfer Protocol (SMTP) server for delivery.

The following table lists some of these commonly used classes −

attached file

represents a file attached to an email.

collection of attachments

stores attachments to be sent as part of an email message.

email address

represents the address of an email sender or recipient.

collection of email addresses

stores email addresses associated with an email message.

mail message

represents an email message that can be sent using the smtpclient class.

smtp client

allows applications to send email using the simple mail transfer protocol (smtp).

smtpe exception

represents the exception that is thrown when smtpclient is unable to complete a send or sendasync operation.

the smtpclient class

The smtpclient class allows applications to send email using the Simple Mail Transfer Protocol (smtp).

the following are some of the commonly used properties of the smtpclient class −

client certificates

specifies which certificates should be used to establish the secure sockets layer (ssl) connection.

credentials

gets or sets the credentials used to authenticate the sender.

enable ssl

specifies whether smtpclient uses secure sockets layer (ssl) to encrypt the connection.

host

gets or sets the name or ip address of the host used for smtp transactions.

port

gets or sets the port used for smtp transactions.

See Also:  How to Configure Gmail SMTP | Cloudways Help Center

waiting time

gets or sets a value that specifies the amount of time after which a synchronous send call times out.

use default credentials

gets or sets a boolean that controls whether default credentials are sent with requests.

the following are some commonly used methods of the smtpclient class −

delete

sends an outgoing message to the smtp server, gracefully ends the tcp connection, and releases all resources used by the current instance of the smtpclient class.

delete (boolean)

sends an outgoing message to the smtp server, gracefully ends the tcp connection, releases all resources used by the current instance of the smtpclient class, and optionally removes managed resources.

send completed

raises the submit completed event.

send(mail message)

sends the specified message to an smtp server for delivery.

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.

sendasync(mail message, 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.

sendasync(string, string, string, string, object)

sends an email message to an smtp server for delivery. the message sender, recipients, subject, and message body are specified using string objects. 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.

See Also:  Tạo yahoo mail không cần số điện thoại

send sync

cancels an asynchronous operation to send an email message.

sendmailasync(mail message)

sends the specified message to an smtp server for delivery as an asynchronous operation.

sendmailasync(string, string, string, string)

sends the specified message to an smtp server for delivery as an asynchronous operation. . the message sender, recipients, subject, and message body are specified using string objects.

tostring

returns a string representing the current object.

The following example demonstrates how to send mail using the smtpclient class. the following points should be noted in this regard −

Leave a Reply

Your email address will not be published. Required fields are marked *