Setting mailServerName in C# .Net for email feedback form
Posted on 2007-11-16
I'm writing an application that has a html feedback form included. I am trying to send the information back through email but am having difficulty when setting the MailServerName.
This is the code I am using
private void SendMail(string from, string body)
string mailServerName = "smtp.MyServerName.com";
MailMessage message = new MailMessage(from, "email@example.com", "feedback", body);
SmtpClient mailClient = new SmtpClient();
mailClient.Host = mailServerName;
The error that I am getting when I run the script is "SmtpException was unhandled by User code - Failure Sending Mail" and it points to the line mailClient.Send(message);
So I figure it is having trouble when I am putting in the ServerName, I'm new to this, is there anyway I can change this around to take the IP address instead to see if that works?