Sending Email from an ASP.NET web application is a simple task.
For sending Email from ASP.NET web application we need to add one namespace,
using System.Net.Mail;
After this we can create a method , sendEmail().
public void sendEmail()
{
                    MailMessage message = new MailMessage();
                    message.From = new MailAddress("test@gmail.com");
                    message.To.Add(new MailAddress("test1@gmail.com"));
                    message.Subject = "Sending an email from ASP.NET web application";
                    message.Body = "Your Email Content here…";
                    SmtpClient client = new SmtpClient();
                    client.Host = "Give your mail server IP";
                    client.Port = Put port number;
                    client.Send(message );
                   
}
You can use this function anywhere from application.
 
No comments:
Post a Comment