C# 自代mail发送邮件的问题
private void timeSendMsg_Tick(object sender, EventArgs e)
{
string topic = string.Empty;
string content = string.Empty;
string email= string.Empty;
foreach (DataGridViewRow row in gvMain.Rows)
{
topic = row.Cells[ "topic "].Value.ToString();
content = row.Cells[ "content "].Value.ToString();
MailSender.sendMail(topic, content, email);
MessageDAO.updateSendFlag(row.Cells[ "ID "].Value.ToString());
}
lbMessage.Items.Add( "发送成功 " + gvMain.Rows.Count + "条 ");
bindData();
}
public static bool sendMail(string strSubject,string content,string eMailAddress) {
if (eMailAddress.Length < 2)
{
return false;
}
bool hasSend = true;
string strSMTPServer = ConfigurationSettings.AppSettings[ "smtpAddress "];
string strSMTPUser = ConfigurationSettings.AppSettings[ "smtpUser "];
string strSMTPPassword = ConfigurationSettings.AppSettings[ "smtpPassword "];
string strFrom = strSMTPUser;
SmtpClient client = new SmtpClient(strSMTPServer);
client.Credentials = new NetworkCredential(strFrom, strSMTPPassword);
client.DeliveryMethod =