Advertisement
Guest User

Untitled

a guest
Aug 16th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. I am storing the email of the user in session
  2. var v = //login query
  3. Session["LoggedUserEmail"] = v.email.ToString();
  4.  
  5. Then after login I want to send an email to the current logged in user and for that purpose I am passing Session["LoggedUserEmail"] in Msg.To.Add but its not working.
  6. This is what I am doing
  7.  
  8. public void Execute(IJobExecutionContext context)
  9. {
  10.  
  11. System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
  12.  
  13. Msg.From = new MailAddress("abc@gmail.com");
  14.  
  15. Msg.To.Add(Session["LoggedUserEmail"].ToString());
  16. Msg.Subject = "Email";
  17. Msg.Body = "Hi";
  18. Msg.IsBodyHtml = true;
  19.  
  20. SmtpClient smtp = new SmtpClient();
  21. smtp.Host = "smtp.gmail.com";
  22. smtp.Port = 587;
  23. smtp.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "xxxxxxx");
  24. smtp.EnableSsl = true;
  25. smtp.Send(Msg);
  26. Response.Write("Email Sent");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement