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 =
"";}
Blocked AccountPosted Aug 12, 2008, 6:56 AM
Make some changes in your code and then try.
MailAddress mailAddress = new MailAddress("[email protected]");
mess.From = mailAddress;
SmtpClient smtp = new SmtpClient();
smtp.Host = "localhost";
if again mail not sent then check smtp server is configured or not in your system.