Sometimes we need to send emails from our Web application without any SMTP setup. For example, sending message with important website updates.
We can send emails from a server IP address without specifying an mail credentials. This is done via IIS and hosting a web page on IIS. The server IIS must support SMTP and emails.
Setup IIS for Emails
- Launch IIS
- Select default SMTP Virtual Server, right click on it and select Properties.
- General tab > Advanced : Add your local IP address
- Hit OK
Use SmtpClient to send Emails
Now, your IIS is all set to send emails from your local IP address.
Create an ASP.NET Website or use your existing website and write the below code.
On our case, we have a simple ASP.NET web page and a button. On the button click event hander, this code sents an email. You can download the attached code.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Net.Mail;
- using System.Net;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SmtpClient ss = new SmtpClient("<Your Local IP Addres>");
- ss.Port = 25;
- ss.UseDefaultCredentials = true;
- ss.Send("<From Mail>", "<To Mail>", "<Subject>", "<Body message>");
- }
- }
- }
Here are couple of more articles on how to send emails in C#.

iqra imtiazPosted Sep 6, 2013, 7:32 AM
how could i mail large amount of text from my application...as i use databinding in my project in windows phone...how i perform this task...plz help me..
Pankaj PandeyPosted Jun 19, 2013, 4:02 AM
yes you can...i think you are looking for bulkmailing...am i right?if yes then contact me for more information over [email protected],,,,some rules that you need to use for bulkmailing..
Ravi ShekharPosted Jun 19, 2013, 3:26 AM
I got the the mail but its too late. sir can we use this method commercially
Ravi ShekharPosted Jun 19, 2013, 3:05 AM
I am not able to sent mail using above code. No error found but no mail send and recieve. when i checked this location C:\Inetpub\mailroot\Queue . this is empty..
suresh senthurpandiPosted Mar 24, 2013, 11:46 AM
I just want to update some points here. Before executing the code, you have to ensure the settings in smtp server, INETMGR->right click in default smtp virtual server->click properties->click tab access->click relay button->select all except the list below->ok->apply. After the sending the email go the location "C:\Inetpub\mailroot\Queue", you can find your sent mail.