asp.net发送邮件奇慢!
我记得我以前用asp发送邮件,一次发送100个邮件地址,大概10秒钟都不用。
现在我用asp.net发送邮件,一次发送10个邮件地址,大概要用到120秒钟(本地机器测试),我把他放到服务器上,程序就出错了。
我把程序代码贴出来,请帮我看看
public void addbbsname(object sender, System.EventArgs e)
{
string sql="select top 10 id,username,password,email,ispost from Mailmember where ispost=0 order by id";
SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
SqlCommand cmd1=new SqlCommand(sql,conn);
SqlDataReader dr1=cmd1.ExecuteReader();
while (dr1.Read())
{
//发送邮件
PostMail(dr1["username"].ToString(),dr1["password"].ToString(),dr1["email"].ToString());
//更新状态
update(dr1["id"].ToString());
}
dr1.Close();
conn.Close();
}
public void PostMail(string username,string password,string email)
{
//邮件标题
string s= subject.Text.Trim();
//邮件内容
string m=brReplace(memo.Text);
string st="";
st="尊敬的用户,<b>";
st+=username+"</b><br>";
st+="您在本站的密码:";
st+=password+"<br>";
st+="<br>";
st+=m+"<br><br>";
st+="感谢您长期对<a href=http://www.javavsnet.com target=_balnk>Java、.Net技术网</a>支持。<br><a href=http://www.javavsnet.com target=_balnk>Java、.Net技术网</a>";
MailMessage MailTo=new MailMessage();
MailTo.From="webmaster@javavsnet.com";
MailTo.To=email;
MailTo.Subject=s;
MailTo.BodyFormat=MailFormat.Html;
MailTo.Body=st;
SmtpMail.SmtpServer ="61.19.12.2";
SmtpMail.Send(MailTo);
}
public void update(string id)
{
string insertsql="update Mailmember set ispost=1 where id="+id;
SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
SqlCommand cmd=new SqlCommand(insertsql,conn);
cmd.ExecuteNonQuery();
conn.Close();
}