Click here to Skip to main content
15,937,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m not able to send e-mail when i published my web application on iis7. when i run my application on local machine( development server) both ports 25 and 587 works and emails are sent.
Is this because of port number?Should i use Port 25? .Or do i need to do some extra settings in my iis regarding sending emails?

Below is my code:--
MailMessage mailMessage = new MailMessage();

                mailMessage.From = new MailAddress("");
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.IsBodyHtml = true;
                mailMessage.Priority = MailPriority.High;
                mailMessage.BodyEncoding = Encoding.UTF8;
                mailMessage.SubjectEncoding = Encoding.UTF8;

                mailMessage.To.Add(new MailAddress(recepientEmail));

                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(body);
                htmlView.ContentType = new System.Net.Mime.ContentType("text/html");

                SmtpClient smtp = new SmtpClient("", 587);
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential();
                NetworkCred.UserName = "";
                NetworkCred.Password = "abcd";

                smtp.UseDefaultCredentials = false;
                smtp.Credentials = NetworkCred;
                smtp.Port = 587;


Help Me Please...I am not able to find out exactly what the problem is.
Updated 10-Jul-14 21:48pm

1 solution

dear just take the help of google.

this link may help you[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900