本文介绍了在电子邮件正文中发送文本框值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的先生.. 我有一个带有文本框的注册表。我想发送邮件包含电子邮件正文中的所有字段.. 这里是我的编码..我使用此代码,但这些值没有显示在邮件中 sendMailToAdmin(txtUsername.Text,txtFname.Text,txtCity.Text,txtEmail.Text,txtPhone.Text); txtUsername.Text = ; txtPassword.Text = ; txtFname.Text = ; txtCity.Text = ; txtState.Text = ; txtCountry.Text = ; txtEmail.Text = ; txtPhone.Text = ; Response.Redirect( registered.aspx); lblSuccess.Text = 检查您的电子邮件以获取登录信息。< br>您的帐户将在48小时。; 受保护 void sendMailToAdmin( string uname, string name, string city,字符串电子邮件,字符串电话) { MailMessage myMsg = new MailMessage(); myMsg.From = new MailAddress( ****@****.***); myMsg.To.Add(email); myMsg.Subject =新用户电子邮件 ; myMsg.Body =新用户信息 ; //您的远程SMTP服务器IP。 SmtpClient smtp = new SmtpClient(); smtp.Host =smtp.gmail.com ; smtp.Port = 587; smtp。凭证=新的System.Net.NetworkCredential( ****@****.*** , ******** ); smtp.EnableSsl = true; smtp.Send(myMsg); }< / br> 解决方案 你好, 尝试重写你的功能,如下所示。 protected void sendMailToAdmin( string uname, string name, string city, string email, string 电话) { MailMessage myMsg = new MailMessage(); myMsg.From = new MailAddress( **** @ mail.com); myMsg.To.Add(电子邮件); myMsg.Subject = 新用户电子邮件; myMsg.Body = 新用户信息\ n \\ n用户名: + uname + \ nFull名称: + name + \ nCity: + city + \ nEmail: +电子邮件+ \ nPhone: + phone ; // 您的远程SMTP服务器IP。 SmtpClient smtp = new SmtpClient(); smtp.Host = smtp.gmail.com; smtp.Port = 587 ; smtp.Credentials = new System.Net.NetworkCredential( **** @ mail.com, pass ***); smtp.EnableSsl = true ; smtp.Send(myMsg); } 问候, myMsg.IsBodyHtml = true; myMsg.Body = txtUsername.Text +< br /> + txtPassword.Text +< br /> + txtFname.Text +< br /> + txtCity.Text +< br /> + txtState.Text +< br /> + txtCountry.Text +< br /> + txtEmail.Text +< br /> + txtPhone.Text; 问候..:笑: Dear sir ..I have a registration form that has text boxes .i want to send a mail containaning all fields in the body of email..here is my coding..i use this code but but these values is not showing in mailsendMailToAdmin(txtUsername.Text, txtFname.Text, txtCity.Text, txtEmail.Text, txtPhone.Text);txtUsername.Text = "";txtPassword.Text = "";txtFname.Text = "";txtCity.Text = "";txtState.Text = "";txtCountry.Text = "";txtEmail.Text = "";txtPhone.Text = "";Response.Redirect("registered.aspx");lblSuccess.Text = "Check Your Email For Login Information.<br>Your account will be activated within 48 hours."; protected void sendMailToAdmin(string uname, string name, string city, string email, string phone){ MailMessage myMsg = new MailMessage(); myMsg.From = new MailAddress("****@****.***); myMsg.To.Add(email); myMsg.Subject = "New User Email "; myMsg.Body = "New User Information"; // your remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("****@****.***", "********"); smtp.EnableSsl = true; smtp.Send(myMsg);}</br> 解决方案 Hello,Try rewriting you function as shown below.protected void sendMailToAdmin(string uname, string name, string city, string email, string phone){ MailMessage myMsg = new MailMessage(); myMsg.From = new MailAddress("****@mail.com"); myMsg.To.Add(email); myMsg.Subject = "New User Email "; myMsg.Body = "New User Information\n\nUser Name: " + uname + "\nFull Name : " + name + "\nCity : " + city + "\nEmail : " + email + "\nPhone : " +phone; // your remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("****@mail.com", "pass***"); smtp.EnableSsl = true; smtp.Send(myMsg);}Regards,myMsg.IsBodyHtml = true;myMsg.Body = txtUsername.Text+ "<br />" +txtPassword.Text + "<br />" +txtFname.Text+ "<br />" +txtCity.Text + "<br />" +txtState.Text+ "<br />" +txtCountry.Text+ "<br />" +txtEmail.Text+ "<br />" +txtPhone.Text ;Regards..:laugh: 这篇关于在电子邮件正文中发送文本框值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 01:59