Using SMTP server settings from web.config

Sending emails in ASP.NET using SMTP server settings is a feature that is always requested by users, since it allows you to contact users or visitors of your ASP application. In this article, I will give you a step-by-step guide on how to set up the SMTP server settings from web.config

1. In Visual Studio, first create a mail and a Web form:


2. As you can see, you are creating a simple form. Now, configure the web.config file with this code to make the web form work:



      <smtp deliveryMethod="Network">

        <network host="" port="587" userName="" password="YourPass" enableSsl="true"/>




3. Now, go to your application, and test the web form:

2 3

4. As you can see the message was sent without problems

5. The starting code for the WebForm in c# is:

using System.Net.Mail;

MailMessage mMsg = new MailMessage("",this.txtTo.Text);

        mMsg.Subject = this.txtSubject.Text;

        mMsg.Body = this.txtContent.Text;

        SmtpClient smtpClient = new SmtpClient();


The starting code for is:

Imports System.Net.Mail

 Dim mMsg As New MailMessage("", Me.txtTo.Text)

mMsg.Subject = Me.txtSubject.Text

mMsg.Body = Me.txtContent.Text

    Dim smtpClient As New SmtpClient()



6. If you need to do to configure your SMTP from web.config, to work with Arvixe smtp, just change the port to “25” and host use the server address.

This concludes Using SMTP server settings from web.config

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez

Tags: , , , , , , , , , , , , , , | Posted under ASP .NET 2, DotNetPanel Administration, WebsitePanel Tutorials, Windows Server Admin | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

2 Comments on Using SMTP server settings from web.config

  1. NAIF says:


Leave a Reply

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