Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I am storing the email of the user in session
- var v = //login query
- Session["LoggedUserEmail"] = v.email.ToString();
- 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.
- This is what I am 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");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement