Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
//mail sending
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("abc@gmail.com");
            mail.To.Add("abc@gmail.com");

            //to send mail on textbox value use this code.
            mail.To.Add("abc@gmail.com");
            mail.IsBodyHtml = true;

            mail.Subject = "ABC";

            mail.Body = "this is mail body";
            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "9876543210");
            smtp.EnableSsl = true;
            smtp.Send(mail);

            TxtFullName.Text = "";
            TxtEmailID.Text = "";
            TxtContactNo.Text = "";
            TxtFeedback.Text = "";

            LblMsg.Text = "Your Mail is Submited...";


i am used above code for Email sending, it is work well project are run as Local host....
but when project are run on Server, then mail are not send... it is display the error...

Error Is :-

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


HTML
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Thanx in advance.
Posted
Updated 23-Jul-14 23:52pm
v3
Comments
ashok rathod 24-Jul-14 5:03am    
@Harnis : Please Suggest what exact error you are getting. The most common problem is with credentials and port is not opened for communication
Harnis Findoliya 24-Jul-14 5:57am    
i am getting above error.
Thanks7872 24-Jul-14 5:06am    
And we suppose to guess the error? Why you think so?
Harnis Findoliya 24-Jul-14 5:54am    
above error is occure...
Thanks7872 24-Jul-14 6:19am    
Copy error, and paste it in google.

1 solution

Hi, you have to add smtp hostname or smpt servername before smpt.send(mail)

see the link below:
Send Mail / Contact Form using ASP.NET and C#[^]
 
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