Last post Dec 07, 2017 07:33 PM by PatriceSc
Dec 07, 2017 06:18 PM|jamminjay|LINK
I Have an intranet site which does various things internally
I wondered if its possible to enter the smtp server in the web.config but when i click a button is it possible to send a preformatted email from the currently logged in user
I thought it might be possibly by either interrogating the securityprincipal or maybe from the users mail profile
Dec 07, 2017 06:42 PM|mgebhard|LINK
If the user is logged in, the user's email address is accessible, and there is an SMTP service available then yes it is possible to send the user an email.
Dec 07, 2017 07:12 PM|ryanbesko|LINK
When constructing the email you can do this to make it appear like it came from anyone you wish:
var mail = new MailMessage();
mail.From = new MailAddress("firstname.lastname@example.org", "Ryan Besko");
Dec 07, 2017 07:33 PM|PatriceSc|LINK
You are using Windows authentication? You could use https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal(v=vs.110).aspx
You have a method to find the UserPrincipal from User.Identity.Name and then you can use the EmailAddress property.