How to pass parameters into an HTML email template from C# Windows application to Send an email -


hi need send email using template in c# windows application . had created template unable pass parameters through html template. here template using.

for html template calling in windows application , sending through gmail smtp. able send mail unable pass parameters it. please me out.here code calling in windows application

try {   using (streamreader reader = file.opentext("h:\\visitor management_project\\visitor management_project\\visitor management_project\\emailtemplate.htm"))   {      smtpclient smtpserver = new smtpclient("173.194.67.108", 587);      smtpserver.usedefaultcredentials = false;      smtpserver.deliverymethod = smtpdeliverymethod.network;      smtpserver.credentials = new system.net.networkcredential("ambarishkesavarapu@gmail.com", "*******");      //smtpserver.port = 587;      smtpserver.host = "smtp.gmail.com";      smtpserver.enablessl = true;      message = new mailmessage();      message.subject = "visitor arrived";      //message.subjectencoding = system.text.encoding.utf8;      message.isbodyhtml = true;      message.body = "emailtemplate.htm";      //message.bodyencoding = system.text.encoding.utf8;      message.from = new mailaddress("ambarishkesavarapu@gmail.com");      message.to.add(lblcpemail.text);      message.priority = mailpriority.high;      message.body = reader.readtoend();      message.deliverynotificationoptions = deliverynotificationoptions.onfailure;      smtpserver.send(message);    }  }  catch (exception ex)  {    messagebox.show(ex.message);  } 

how add parameters html template getting parameters of in same page in textboxes. please me out

i think discovered answer yourself, keep posting answer instead.

in case using windows forms , not windows presentation forms (the different design part , many new features not have on windows forms), have done (to send email):

public void sendemail(string _from, string _fromdisplayname, string _to, string _todisplayname, string _subject, string _body, string _password)     {         try         {             smtpclient _smtp = new smtpclient();              mailmessage _message = new mailmessage();              _message.from = new mailaddress(_from, _fromdisplayname); // email address , full name              _message.to.add(new mailaddress(_to, _todisplayname)); // recipient email address , recipient full name // cannot edited              _message.subject = _subject; // subject of email             _message.body = _body; // body of email              _smtp.port = 587; // google mail port             _smtp.host = "smtp.gmail.com"; // google mail address             _smtp.enablessl = true;             _smtp.usedefaultcredentials = false;             _smtp.credentials = new networkcredential(_from, _password); // login gmail using email address , password              _smtp.deliverymethod = smtpdeliverymethod.network;             _smtp.send(_message);              showmessagebox("your message has been sent.", "success", 2);         }          catch (exception ex)         {             showmessagebox("message : " + ex.message + "\n\neither e-mail or password incorrect. (are using gmail account?)", "error", 1);         }     } 

and using this:

sendemail(textbox2.text, textbox5.text, textbox3.text, "your_full_name", textbox4.text, textbox6.text, "your_email_password"); 

here image:

enter image description here

may answer you.

cheers!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -