We have all come across applications such as Craigslist, which allows you to email ads that you come across to others; as well as mobile apps that offer the ability to send emails from your current Email account, using their SMTP settings and port.

To begin, let’s create a new application. Our Default.aspx needs seven TextBox Controls, one Button, and one Literal, or Label Control. I will be organizing the text boxes into table to keep things a bit more organized.

Moving along, let’s create our Button OnClick Event and jump into our Code Behind. What we first need to do before getting ahead of ourselves is add the System.Net.Mail namespace to our project. Now we can jump back into our OnClick. We will be using a Try..Catch Statement for the Authentication aspect.

In the Try portion we will be creating a message object of type MailMessage, which will contain the entire message, along with the to, from and subject information. We will also be creating an instance of a SMTP Client that will be set to the SMTP server the user inputs.

We will now be setting some of the properties to our new SmtpClient we made, as checking the user input with the correct Network Credentials for the Server they are trying to use.

When we are able to complete all of this successfully, we will then set the Label or Literal Control to a Confirmation message to inform the user of the success.

If this is unable to complete for any reason, the user will receive an Exception message for the given reason in the form of the Literal or Label Control.

And there you have it; we have now created an Emailing application with Authentication, which we can include in an assortment of possible applications. If you have any other questions or concerns and have not yet downloaded the Source Code for this project, I strongly suggest doing so. Seeing it in its entirety can help clear up many of your questions. Thank you for your time and I hope this has been helpful, take care.

Download Source Files