ASP.NET TIPS: SENDING EMAIL USING ASP.NET (GMAIL OR YOUR SERVER)

using System.Net.Mail;
using System.Net;
MailMessage mail = new MailMessage();
mail.To.Add("**@gmail.com");
mail.To.Add("**@gmail.com");
mail.From = new MailAddress("**@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail from devenvexe" +
"using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("***@gmail.com", "******");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);

0 Comments

Featured Post

Improving C# Performance by Using AsSpan and Avoiding Substring

During development and everyday use, Substring is often the go-to choice for string manipulation. However, there are cases where Substring c...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts