Unable to send Mails through SMTP using Asp.Net -
i need send mails 60 100 students @ time when click on send button. working if have 6 7 students when start sending 60 students code shows following error
insufficient system storage. server response was: many emails per connection.
here code
protected void btnsend_click(object sender, eventargs e) {
if (drptopics.selectedvalue == "-1") { response.write(@"<script language='javascript'>alert('please select 1 topic');</script>"); } else { sqlconnection conn = new sqlconnection(); conn.connectionstring = "data source=xxxx; user id=sa; password=xxxx; initial catalog=xxxx; integrated security=sspi;"; conn.open(); sqlcommand cmd = new sqlcommand(); cmd.connection = conn; cmd.commandtext = "select email_1 student_info branch_code='ap' , student_id in(select student_id admissions branch_code='ap' , batch_id='" + txtbatchid.text + "')"; cmd.commandtype = commandtype.text; sqldataadapter da = new sqldataadapter(cmd); da.selectcommand = cmd; dataset ds = new dataset(); da.fill(ds); if (ds.tables[0].rows[0][0] != null) { int count = ds.tables[0].rows.count; (int = 0; < count; i++) { mailmessage mm = new mailmessage(); mm.to.add(new mailaddress(ds.tables[0].rows[i][0].tostring())); mm.from = new mailaddress("xxxxx@abc.com"); mm.subject = "sms , interview questions of oracle 11g dba"; mm.isbodyhtml = true; //day 1 architecture 1 if (drptopics.selectedvalue == "1") { attachment attachment1 = new attachment(server.mappath("~/oracle 11g dba/day 1/architecture-1-i.doc")); //create attachment mm.attachments.add(attachment1); attachment attachment2 = new attachment(server.mappath("~/oracle 11g dba/day 1/architecture1-s.doc")); //create attachment mm.attachments.add(attachment2); } //day 2 architecture 2 else if (drptopics.selectedvalue == "2") { attachment attachment1 = new attachment(server.mappath("~/oracle 11g dba/day 2/architecture-2-i.doc")); //create attachment mm.attachments.add(attachment1); attachment attachment2 = new attachment(server.mappath("~/oracle 11g dba/day 2/architecture2-s.doc")); //create attachment mm.attachments.add(attachment2); } mm.body = "<html><head><body><h1>thank choosing wilshire</h1><br><b>team wilshire<b></body></head></html>"; smtpclient s = new smtpclient("smtp.net4india.com"); s.send(mm); } }
}
please tell me solution........................
smtpclient.sendasync()
lead other problems (smtp servers set maximum mail number per minute avoid spam)!
since mails identical, solution 1 single mail recipients hidden recipients (bcc
)!
mailmessage mm = new mailmessage(); (int = 0; < count; i++) { mm.bcc.add(new mailaddress(ds.tables[0].rows[i][0].tostring())); } mm.to.add(new mailaddress("xxxxx@abc.com"); mm.from = new mailaddress("xxxxx@abc.com"); mm.subject = "sms , interview questions of oracle 11g dba"; .... smtpclient s = new smtpclient("smtp.net4india.com"); s.send(mm);
Comments
Post a Comment