Can email be dynamic so it can find email of the owner of the website it self
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?
<!-- indstillinger for send mail -->
<add key="SendEmailFrom" value="[email protected]"/>
<add key="EmailPassword" value="1234567890"/>
<add key="EmailEmne" value="Besked fra din hjemmeside"/>
My controller
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
};
try
{
//Forbind til SMTP i webconfig
var smtp = new SmtpClient();
smtp.Send(besked);
}
catch (Exception ex)
{
throw ex;
}
}
Can email be dynamic so it can find email of the owner of the website it self
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
App settings i webconfig
My controller
is working on a reply...