mysql - i want to sent mail at a time all employees which is stored in my database using asp.net -


i have database in multiple records available. want pick record , sent mail employees how can do. solution of that.

code below

protected void btnsend_click(object sender, eventargs e) {    //retrieve email addresses database.     //i'm assuming table "members" , database "testdb"     //on localhost.       sqlconnection con = new sqlconnection("server=(local);database=testdb;uid=sa;pwd=yourpassword");     sqlcommand cmd = new sqlcommand();     cmd.commandtype = commandtype.text;     cmd.commandtext = "select email members";     cmd.connection = con;     datatable memberstable = new datatable();     sqldataadapter da = new sqldataadapter(cmd);     con.open();     da.fill(memberstable);     con.close();       //send email each recepient now.       mailmessage msgmail = new mailmessage();       foreach (datarow row in memberstable.rows)     {         msgmail.to.add(row["email"]);     }       msgmail.from = "webmaster@yoursite.com";     msgmail.subject = "hi test email";       msgmail.isbodyhtml = true;     string strbody = "<html><body><b>hello world</b>" +       " <font color=\"red\">asp.net</font></body></html>";     msgmail.body = strbody;       smtpmail.send(msgmail);  } 

you can refer link


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -