Hello World!!
Today I would I like to share my knowledge regarding “Send an
E-Mail using ASP.Net C#”
Using C#.NET it’s quite easy to send e-mail. I have used this
code to send e-mail viva godaddy.com mail server.
For “web.config” file, you may follow these lines of code,
this code works fine for me after trying
many other options.
Pre Requirement is you have to create a email address for your domain name for example if your domain name is xyzblog.com then your email should be no-reply@xyzblog.com.
I have tested this on localhost.
<system.net> <mailSettings> <smtp from="no-reply@Mydomain.com"> <network host="smtpout.secureserver.net" userName="Myemail@mydomain.com" password="Mypassword"/> </smtp> </mailSettings> </system.net>
if you want to use Gmail.com follow these code lines.<system.net> <mailSettings> <smtp from="iam@gmail.com"> <network host="smtp.gmail.com" port="25" userName="im@gmail.com" password="mypassword" enableSsl="true"/> </smtp> </mailSettings> </system.net>In code behind.using System.Net.Mail;bool SendEmail(string toAddress,string subject,String PersonName) { try { MailMessage MM = new MailMessage(); MM.From = new MailAddress("Myemail@mydomain.com", PersonName); MM.To.Add(new MailAddress(toAddress)); MM.Subject = subject; MM.Body = "<br />Thank you!</span>”; MM.IsBodyHtml = true; SmtpClient mySMTP = new SmtpClient(); mySMTP.Send(MM); } catch { return false; } return true; }
Comments
Post a Comment