在asp.net中发送电子邮件发送密码,而不是电子邮件 [英] sending email in asp.net sends password instead of email
本文介绍了在asp.net中发送电子邮件发送密码,而不是电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用户已经注册成功后发送电子邮件。但它发送密码FROM部分,而不是发送电子邮件一样abc@gmail.com这里发送1234kjfh。什么我在这里丢失?
I am trying to send email after user has been registered successfully. but it sends password in FROM section instead of sending email like abc@gmail.com here it sends 1234kjfh. what am I missing here?
string name=txtfirstname.Text;
string fileName = Server.MapPath("~/App_Data/TextFile.txt");
string mailBody = File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", txtfirstname.Text);
mailBody = mailBody.Replace("##Email##", email);
mailBody = mailBody.Replace("##Phone##", txtphone.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Re: Activate your account for AIS FORUM";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("abc@gmail.com", "1234kjfh");
myMessage.To.Add(new MailAddress(txtemail.Text, email));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.EnableSsl = true;
mySmtpClient.Send(myMessage);
PLZ帮助!
推荐答案
您在这里的东西
新的MailAddress(地址,显示名)
new MailAddress(address, displayName)
所以,你必须添加显示名称为1234kjfh
so, you have added display name as "1234kjfh"
更新您的code如下。
Update your code as follow.
string name=txtfirstname.Text;
string fileName = Server.MapPath("~/App_Data/TextFile.txt");
string mailBody = File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", txtfirstname.Text);
mailBody = mailBody.Replace("##Email##", email);
mailBody = mailBody.Replace("##Phone##", txtphone.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Re: Activate your account for AIS FORUM";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("abc@gmail.com", "abc@gmail.com");
myMessage.To.Add(new MailAddress(txtemail.Text, email));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.EnableSsl = true;
mySmtpClient.Send(myMessage);
希望这有助于。
这篇关于在asp.net中发送电子邮件发送密码,而不是电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文