1
Answer

Not able to send newsletter

kawaljit  singh

kawaljit singh

16y
4.4k
1

Need help

I am not able to send the newsletter with the following code in .Net 2.0. All mess are in queue....of mailroot........and if i run this on server.....its shows failur sending mail...

try

{

oldConn.Open();

str = "Select DISTINCT Emails from Email_tbl where status='true'";

oldComm = new OleDbCommand(str, oldConn);

oldRead = oldComm.ExecuteReader();

//objCmd.Connection.Close();

while (oldRead.Read())

{

string emails;

emails = oldRead["Emails"].ToString();

MailMessage mess = new MailMessage();

mess.From = new MailAddress([email protected]);

mess.To.Add(emails);

mess.Subject = txtNewstitle.Text + " somemess";

mess.IsBodyHtml = true;

mess.Body = txtEditor.Text;

SmtpClient smtp = new SmtpClient("localhost");

smtp.Send(mess);

}

}

catch (Exception ex)

{

lblMsg.Text = ex.Message;

}

finally

{

oldConn.Close();

txtEditor.Text = "";

txtNewstitle.Text = "";

}

Answers (1)