<P><SPAN id=span_3635> </SPAN></P>
<P><SPAN><STRONG>我想的是</STRONG></SPAN><SPAN><STRONG>将所有要发送的 Email 地址提出,放到临时表 <BR>每成功发送一个,删掉一个地址</STRONG></SPAN></P>
<P><SPAN><STRONG> </STRONG></SPAN></P>
<P><SPAN><STRONG>但是发送一个删除一个的效果怎么实现呢?</STRONG></SPAN></P>
<P><SPAN><STRONG> </STRONG></SPAN></P>
<P><SPAN><STRONG>报错啊。</STRONG></P>
<P><BR></P></SPAN>
问题补充:
//读取数据库,发送邮件操作
protected void sendEmail()
{
SqlConnection sqlCon = new SqlConnection("server=192.168.*.*;database=&&&&;uid=&&;pwd=&&&&&&");
sqlCon.Open();
SqlTransaction trans;
SqlDataReader reader = null;
string sqlStr = "SELECT MailSubject,MailFrom,MailContent,MailSendTo From Bus_SendEmail";
SqlCommand sqlCom = new SqlCommand();
trans = sqlCon.BeginTransaction();
sqlCom.Connection = sqlCon;
sqlCom.CommandText = sqlStr;
sqlCom.Transaction = trans;
reader = sqlCom.ExecuteReader();
try
{
//int i = 0;
SmtpClient client = new SmtpClient();
while (reader.Read())
{
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network; //发送方式
client.Host = "smtp.163.com"; //邮件服务器
client.Credentials = new System.Net.NetworkCredential("##########", "***********");//身份验证
//string FromEmail = reader.GetString(1);//发送邮件人的地址
string ToEmail = reader.GetString(3); //收件人的地址
MailMessage message = new MailMessage("#######@163.com", ToEmail);//发送方的地址, 接收人的地址
message.Body = reader.GetString(2) + DateTime.Now.ToString();//邮件内容
message.Subject = DateTime.Now.ToString() + reader.GetString(0);//邮件主题
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
message.BodyEncoding = Encoding.UTF8;
client.Send(message);
}