I have created a webform in visual studio. This application is sending an email. BUT I want the FROM address to be the logged in user's email. So for example, if John is logged in with his email and password and he clicks submit, the email will send to Person X but the from address will come from John. I hope this is a clear enough explanation.
This is the code snippet of my sending mail method.
{
MailMessage message = new MailMessage();
message.To.Add(nameddl.Text);
message.From = new MailAddress("");
message.Subject = "Notification";
message.Body = "An new entry has been made that requires your attention.";
message.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
}
So this line, message.From = new MailAddress(User.LoggedIn); this is what I want. BUT how do one code it to work like that, can it be made possible?
NB: This is NOT a MVC Application, just a regular ASP.NET Web form.
**EDIT Still struggling with this one, so if anyone got an idea that would be great?