Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How do I set the smtp "from" to the administrator mail of the page so I do not have to type it manually with the email password etc.
it also send an email for the person who type in his email and that is wrong. It have to send an email to the owner of the site so he knows there is a message. what am i doing wrong there?
Webconfig email settings
<smtp deliveryMethod="Network" from="email@example.com">
<network host="smtp.gmail.com" port="587" enableSsl='true' defaultCredentials='false' userName="firstname.lastname@example.org" password="1234567890"/>
App settings i webconfig
<!-- indstillinger for send mail -->
<add key="SendEmailFrom" value="email@example.com"/>
<add key="EmailPassword" value="1234567890"/>
<add key="EmailEmne" value="Besked fra din hjemmeside"/>
private void SendMail(KontaktModel model)
var fraEmail = new MailAddress(ConfigurationManager.AppSettings["SendEmailFrom"]);
var tilAdresse = new MailAddress(model.Email);
string emne = ConfigurationManager.AppSettings["EmailEmne"];
string body = model.besked;
var besked = new MailMessage(fraEmail, tilAdresse)
Subject = emne,
Body = body
//Forbind til SMTP i webconfig
var smtp = new SmtpClient();
catch (Exception ex)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted