asp.net mvc 4 - How to send email to current logged in user -
i storing email of user in session var v = //login query session["loggeduseremail"] = v.email.tostring(); after login want send email current logged in user , purpose passing session["loggeduseremail"] in msg.to.add not working. doing public void execute(ijobexecutioncontext context) { system.net.mail.mailmessage msg = new system.net.mail.mailmessage(); msg.from = new mailaddress("abc@gmail.com"); msg.to.add(session["loggeduseremail"].tostring()); msg.subject = "email"; msg.body = "hi"; msg.isbodyhtml = true; smtpclient smtp = new smtpclient(); smtp.host = "smtp.gmail.com"; smtp.port = 587; smtp.credentials = new system.net.networkcredential("abc@gmail.com", "xxxxxxx"); smtp.enablessl = true; smtp.send(msg); response.write("email sent"); }
am doing wrong? if yes, there other way job done?
i using quartz.net , implemented ijob interface in mvc controller.
the job executes on different thread 1 schedules it. must pass in data need using jobdatamap when creating/scheduling job.
Comments
Post a Comment