protected void SendBulkEmail(object sender, EventArgs e)
{
string conString = System.Configuration.ConfigurationManager.ConnectionStrings["latestsarkarijob"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
string selectSql = "select * from TBL_subscription";
SqlCommand cmd = new SqlCommand(selectSql, con);
try
{
con.Open();
using (SqlDataReader read = cmd.ExecuteReader())
{
while (read.Read())
{
string x = (read["subscriptionUserEmailID"].ToString());
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add(x);
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
message.From = new System.Net.Mail.MailAddress("info@latestsarkarijob.com", "Latestsarjarijob");
message.Bcc.Add("info@latestsarkarijob.com");
message.Subject = "Test bulk Mail from latest sarkari job team";
message.Body = "this is testing message for testing email message from the body";
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = "ip";
client.Port = 25;
string userName = "info@latestsarkarijob.com";
string password = "********";
client.Credentials = new NetworkCredential(userName, password);
client.Send(message);
lblMessage.Text = "Mail send Successfully";
}
}
}
catch(Exception ex){
Response.Write(ex.Message + ex.Source);
}
finally
{
con.Close();
}
}
please check my code where is error