我的时事通讯有点问题...
让我解释一下:我有一个包含我的电子邮件的 sql 表,没有其他内容,还有一个 sql 表,我在发送邮件后存储邮件,不知何故邮件不会发送,但它会保存邮件。
这一切都设置在一个formview中。
protected void btnSendNewsLetter_Click(object sender, EventArgs e)
{
TextBox subject = (TextBox)fvNewsletter.Row.FindControl("txtSubject");
TextBox body = (TextBox)fvNewsletter.Row.FindControl("txtBody");
string connection = WebConfigurationManager.ConnectionStrings["GreenCollaborationConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(connection);
con.Open();
SqlCommand comm = new SqlCommand("Select Email from MailingList", con);
SqlDataAdapter da1 = new SqlDataAdapter(comm);
GreenDataSet ds1 = new GreenDataSet();
da1.Fill(ds1);
if(ds1.Tables[0].Rows.Count > 0)
{
for (int i = 0; i <= ds1.Tables[0].Rows.Count - 1; i++)
{
string email = ds1.Tables[0].Rows[i].ItemArray[0].ToString();
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.From = new MailAddress("noreply@GreenCollaboration.com", "GreenCollaboration");
mail.To.Add(email);
mail.Subject = subject.Text;
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Body = body.Text;
}
}
}
我希望some1可以帮助我:)