Sending mail through ASP.NET

In this topic, I want to give a tutorial: How to send mail with the help of ASP.NET. Through these codes, you can make your own mail transfer system. Actually you are building a mediator, which helps another account and password to forward your mail to given id. Before writing this code, please get your port id. Like for Google/ Gmail its 587. Here I am gonna use my gmail account. Lets see.

First make a page. Say contact.aspx.


Make a button, ay Submit. And on click, write these codes. And add these library to your cs file. So lets create contact.aspx.cs page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

In place of “mypassword” give your password for the mail id you are using to send (I used Any query, drop a comment.


Deepesh Singh


Please leave your valuable comment.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s