24-Sending an Email

0
516

This Visual Basic Tutorial is all about Sending an Email.
In Visual Basic, sending e-mails are allowed in your application. The System.Net.Mail is the namespace that contains classes  that is used for sending e-mails to a Simple Mail Transfer Protocol (SMTP) server for delivery.

The SmtpClient class allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).

Take note that in sending e-mail you must specify the SMTP host server because the Host and Port properties will be different for various host server.

In here, we will be using Gmail server.

If the STMP server requires you for the authentication, you must need to give the Credentials

 

Sender’s email address should be provided same as the recipients using the MailMessage.From and MailMessage.To properties. Specify  also the content of message by using MailMessage.Body property.

 

Example:

  1. Open the Visual Basic, select “File” on the menu, hit new and create a new project.
    01_helloworld
  2. The New Project dialog will appear.
    create2s
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  3. Design the form this way. See it Below.
    sendemailf1
  4. dd the following code in the code editor.

 

 

Readers might read also:

 

 

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.