如何在asp.net中发送emain [英] how to send emain in asp.net
本文介绍了如何在asp.net中发送emain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在按钮上单击发送电子邮件,有人可以告诉我如何显示指定的字符串不是电子邮件格式的错误
i want to send email on the button click can anybody tell me how i can becoz its showing an error the specified string is not in the email format
protected void submitbtn1_Click(object sender, ImageClickEventArgs e)
{
SmtpClient smtpclient = new SmtpClient();
MailMessage mailmessage = new MailMessage();
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text, chngepswdtxt.Text);
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 587;
mailmessage.From = emailsenderaddress;
MailAddress recepient = new MailAddress("abhimanyu.vij@gmail.com");
mailmessage.To.Add("recepient");
smtpclient.Send(mailmessage);
}
推荐答案
这行代码看起来有些混乱:
This line of code looks a little bit confusing:
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text, chngepswdtxt.Text);
用户名 txtbx和 chngepswd txt看起来不是给我的电子邮件地址字段...
Usernametxtbx and chngepswdtxt looks not email address fields to me...
您没有指定任何主题和正文.
You didn''t specify any subject and body.
mailmessage.Subject = "Your subject";
mailmessage.Body = "Your Body";
欢呼
cheers
MailAddress emailsenderaddress = new MailAddress(Usernametxtbx.Text,emailtxtbx.Text);
现在可以了,我有两个txtbx,一个用于用户名,一个用于电子邮件,现在告诉我解决方案
now its ok here i have two txtbx one s one is for username and one is for email got it now tell me the solution
这篇关于如何在asp.net中发送emain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文