Hi ,

Am developing a Windows application in which one module has to send a report to customers a mail.. the Question is

I use net.mail namespace in c# and here comes the code .

SmtpClient smtp = new SmtpClient();
MailMessage msg = new MailMessage();
smtp.Credentials = new System.Net.NetworkCredential("myusername", "password");
smtp.Port = 587;
//smtp.Port = 465;
smtp.Host = "smtp.gmail.com";
msg = new MailMessage();
msg.From = new MailAddress("fromtxtBox.text");
msg.Subject = subtxtBox.text;
msg.Body = drafttxtBox.text
label1.Text = "mail sent";
catch (Exception ec)


It works good in my previous task bt thn now i always get exception....why is that so....

Please, if you get an error post it up...

Are you having a problem with the code? Any errors at all?


It gives an exception as mail sending failed....

Cool. We need to know what the exception is. Thanks.

@ pro_learner.. That's exactly what I said. Thanks for stressing a little more on the point. ROFL!