Send Email In ASP.NET Without Email And Password

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. 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Net.Mail;  
  8. using System.Net;  
  9. public partial class _Default : System.Web.UI.Page  
  10. {  
  11. protected void Page_Load(object sender, EventArgs e)  
  12. {  
  13. }  
  14. protected void Button1_Click(object sender, EventArgs e)  
  15. {  
  16. SmtpClient ss = new SmtpClient("<Your Local IP Addres>");  
  17. ss.Port = 25;  
  18. ss.UseDefaultCredentials = true;  
  19. ss.Send("<From Mail>""<To Mail>""<Subject>""<Body message>");  
  20. }  
  21. }  
  22. }  
In the above code, SmtpClient object uses your local IP address. Next, set a Port and use default credentials. The last thing is to send email via Send method. The format of the email can be anything you want to put in the Send method.
Here are couple of more articles on how to send emails in C#.