PDA

View Full Version : Cannot sent email from windows form application


dbn10023
12-10-2010, 02:34 PM
I get the following error message from the code below (note: av is turned off) where "HostedDomain" is my dasp domain - thanks in advance for any help.

Message "Failure sending mail."
InnerException {"Unable to connect to the remote server"} System.Exception {System.Net.WebException}


MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("user@HostedDomain.com", "user name");

message.From = fromAddress;
message.To.Add("to@todomain.com");
message.Subject = "subject";
message.IsBodyHtml = false;
message.Attachments.Add(new System.Net.Mail.Attachment(filename));

SmtpClient mailClient = new SmtpClient();
NetworkCredential credential = new NetworkCredential("email@HostedDomain.com", "password");

mailClient.Host = "smtp.HostedDomain.com";
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = credential;

mailClient.Send(message);

wisemx
12-10-2010, 03:45 PM
...Have you tried "localhost" as the host?