当前位置:编程学习 > C#/ASP.NET >>

谁有最新的Asp.net发邮件的代码?(VS2005.net ,C#)

答案:/// 发送在线邮件,0失败,1成功 /// /// /// /// /// public static int WebMailTo(string email_to, string email_subject, string email_messageText) { string swySql = "select email_server,email_user,email_password from XxskyBBS_setup"; SqlConnection swyConn = new SqlConnection(swyConnstr); swyConn.Open(); SqlCommand swyCmd = new SqlCommand(swySql, swyConn); SqlDataReader swyReader = swyCmd.ExecuteReader(); swyReader.Read(); string email_server = swyReader["email_server"].ToString(); string email_user = swyReader["email_user"].ToString(); string email_password = swyReader["email_password"].ToString(); swyReader.Close(); swyReader.Dispose(); swyConn.Close(); swyConn.Dispose(); string email_from = "择优网(mt028.com)<" + email_user + ">"; MailMessage mm = new MailMessage(); mm.BodyFormat = MailFormat.Html; mm.To = email_to; mm.From = email_from; mm.Subject = email_subject; mm.Body = email_messageText; //设置支持服务器验证 mm.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //设置用户名 mm.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/sendusername", email_user); //设置用户密码 mm.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/sendpassword", email_password); SmtpMail.SmtpServer = email_server; int mailok; try { SmtpMail.Send(mm); mailok = 1; } catch { mailok = 0; } return mailok; }看不懂联系我!我这个回答不给分就对不起人了!qq:372895791

上一个:asp.net 代码中写 para[0].Direction=ParameterDirection.Output;数据库中要怎么写;就是想读取那个值
下一个:谁有<ASP.NET信息管理系统开发实例导航>(c#)书中的代码?急需

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,