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(asp.net 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:--
C#
MailMessage mailMessage = new MailMessage();

                mailMessage.From = new MailAddress("abcd@gmail.com");
                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));
                mailMessage.Bcc.Add("abcd@gmail.com");


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

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

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

                smtp.Send(mailMessage);

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

1 solution

dear just take the help of google.

this link may help you
http://forums.asp.net/t/1461829.aspx?Failure+sending+mail+on+IIS7[^]
 
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