ASP.NET发送EMAIL,急急急,为什么我发送不成功。而且cpu 竟然到了100%。问题解决立马给分
string Webmaster=ConfigurationSettings.AppSettings["Webmaster"];
string SMTP=ConfigurationSettings.AppSettings["SMTP"]; MailMessage Mailer=new MailMessage(); Mailer.From=Webmaster;
Mailer.To=user.Email; Mailer.Subject="员工取回密码";
Mailer.Body="你的员工编号为:"+txtFBM.Text+
"\n 密码为:"+user.Password;
Mailer.BodyFormat=System.Web.Mail.MailFormat.Text;
Mailer.Priority=MailPriority.High; SmtpMail.SmtpServer=SMTP;
SmtpMail.Send(Mailer); Message.Text="密码已经发送成功!";
Message.ForeColor=Color.Blue;
string Webmaster=ConfigurationSettings.AppSettings["Webmaster"];
string SMTP=ConfigurationSettings.AppSettings["SMTP"]; MailMessage Mailer=new MailMessage(); Mailer.From=Webmaster;
Mailer.To=user.Email; Mailer.Subject="员工取回密码";
Mailer.Body="你的员工编号为:"+txtFBM.Text+
"\n 密码为:"+user.Password;
Mailer.BodyFormat=System.Web.Mail.MailFormat.Text;
Mailer.Priority=MailPriority.High; SmtpMail.SmtpServer=SMTP;
SmtpMail.Send(Mailer); Message.Text="密码已经发送成功!";
Message.ForeColor=Color.Blue;
解决方案 »
- asp.net mvc2 怎样与非mvc网站合并在一起
- 救命吖!!!非常急。
- .net中如何调用javascript函数
- 网站发布后不能生在word文档: System.UnauthorizedAccessException 末授权妄访问导常。
- DataList为多例,如何只扩大横向间隔,不增加纵向间距.
- 请问这样的架构图用什么软件画好?
- 请教简单问题:点按钮 关闭窗口
- Datagrid中的radiobuttonlist问题
- 如何通过帐号密码登录后进入一个无边框窗口
- 怎樣給DataSet中表t1第gbRow行的字段store_date(即gbRow.store_date)賦空值null?
- datalist中的DataItem问题
- 各位老鸟:在ASP.NET中怎么实现从数据库中提取权限编码自动生成菜单的功能,非常棘手!!!!!
//发送
//MailMessage mail = new MailMessage();
//mail.To = "[email protected]";
//mail.From = "[email protected]";
//mail.Subject = "this is a test email.";
//mail.Body = "Some text goes here";
//
//mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
//mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username"); //set your username here
//mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");//set your password here
//
//SmtpMail.SmtpServer = "smtp.sohu.com";//your real server goes here
//
//SmtpMail.Send( mail );
以下可參考:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim mail As New MailMessage
Dim iLoop1 As Integer
Dim sAttach As String = "c:\usblog.txt"
Dim delim As Char = "," Dim sSubstr As String
mail.To = "[email protected]"
mail.Cc = ""
mail.From = "HAHA"
mail.Subject = "this is a test email."
mail.BodyFormat = MailFormat.Html
mail.Body = "Some text goes here!" For Each sSubstr In sAttach.Split(delim)
Dim myAttachment As MailAttachment = New MailAttachment(sSubstr)
mail.Attachments.Add(myAttachment)
Next
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "0") 'basic authentication
SmtpMail.SmtpServer = "192.168.203.9" 'your real server goes here
SmtpMail.Send(mail)
End Sub
MailMessage mm=new MailMessage();
mm.From="[email protected]";
mm.To="[email protected]";
mm.Subject=this.TextBox3.Text;
mm.Body=this.TextBox1.Text+" "+this.TextBox4.Text; mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //表示基本验证
mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendusername", "abcabc"); //在my_username_here处添加如163这样的身份验证的用户名
mm.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); // 在your_password_here处输入密码
SmtpMail.SmtpServer = "smtp.163.com"; //邮件服务器地址
SmtpMail.Send(mm);
try
{
SmtpMail.Send(mm);
}
catch
{
Response.Write("<script>window.alert('"+"发生故障,邮件没有发送成功"+"')</script>");
return;
}
Response.Write("<script>window.alert('"+"邮件发送成功"+"')</script>");
在IP地址里输入127.0.0.1 确定