I am trying to write a smiple email web program. Whenever I try to get an out going email I keep getting the general message that the computer is denying me access.
"No connection could be made because the target machine actively refused it " I have tried this at different locations.
String to, body, from, subject;
to = TextBoxTo.Text;
from = TextBoxFrom.Text;
subject = TextBoxSubject.Text;
body = TextBoxBody.Text;
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress(to));
mailMessage.From = new MailAddress(from);
mailMessage.Subject = subject;
mailMessage.Body = body;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);
Web.config
<system.net>
<mailSettings>
<smtp>
<network host="smtp.gmail.com" port="587" userName="bob@gmail.com" password="pizza" enableSsl="true" />
</smtp>
</mailSettings>
</system.net>