sendmail - How to get Dynamic Data in email newsletter from the website in asp.net c#? -
i have newsletter design in have bind data dynamically , send mail users in asp.net c# through noreply@xyz.com tried getting error of authentication if knows please sort out problem.
mailmessage msg = new mailmessage(); mailaddress frommail = new mailaddress("abc@gmail.com"); // sender e-mail address. msg.from = frommail; // recipient e-mail address. msg.to.add(new mailaddress("xyz@gmail.com")); // subject of e-mail msg.subject = "send gridivew in email"; msg.body += "please check below data <br/><br/>"; msg.body += getgridviewdata(gvuserinfo); msg.isbodyhtml = true; string ssmtpserver = ""; ssmtpserver = "smtp.gmail.com"; smtpclient = new smtpclient(); a.host = ssmtpserver; a.enablessl = true; a.port = 587; a.deliverymethod = system.net.mail.smtpdeliverymethod.network; a.credentials = new networkcredential("abc@gmail.com", "abc@123"); a.send(msg);
grid view code
public string getgridviewdata(gridview gv) { stringbuilder strbuilder = new stringbuilder(); stringwriter strwriter = new stringwriter(strbuilder); htmltextwriter htw = new htmltextwriter(strwriter); gv.rendercontrol(htw); return strbuilder.tostring(); }
Comments
Post a Comment