i have code
protected void aspxbutton1_click(object sender, eventargs e) { mailmessage mail = new mailmessage(); mail.from = new mailaddress("paragonadmin@qss.co.za", "paragon admin"); mail.to.add(new mailaddress("dewald@qss.co.za", "appointment scheduled")); mail.subject = "enter mail subject"; mail.body = "enter mail body"; smtpclient smtpclient = new smtpclient("smtp.qss.co.za"); smtpclient.credentials = new system.net.networkcredential("paragonadmin@qss.co.za", "123456"); object state = mail; //event handler asynchronous call smtpclient.sendcompleted += new sendcompletedeventhandler(smtpclient_sendcompleted); try { //smtpclient.send(mail); smtpclient.sendasync(mail, state); } catch (exception ex) { /* exception handling code here */ } } void smtpclient_sendcompleted(object sender, system.componentmodel.asynccompletedeventargs e) { mailmessage mail = e.userstate mailmessage; if (!e.cancelled && e.error != null) { aspxlabel1.text = "mail sent successfully"; } }
it supposed send mail asynchronous in application, reason "failure sending mail" error message.
any advice
Comments
Post a Comment