I am trying to send email using the following code and get the error above.
There is two emails being sent the first one seems to get delivered fine, the code below doesn't seem to work.
Can anyone help please?
using (var mail = new MailMessage(fromEmail.Trim(), ToEmail.Trim()))
{
mail.IsBodyHtml = true;
bodyText = bodyText.Replace("**Message**", Message);
// populate the message
mail.Subject = subject;
mail.Body = bodyText;
// send it
var smtpClient = new SmtpClient();
smtpClient.Send(mail);
}
The config:
<system.net>
<mailSettings>
<smtp from="test@foo.com">
<network defaultCredentials="true" port="25" host="127.0.0.1" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>