0

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 .

try
{
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.To.Add("totxtBox.text");
msg.Subject = subtxtBox.text;
msg.Body = drafttxtBox.text
smtp.Send(msg);
label1.Text = "mail sent";
               
}
catch (Exception ec)
{

   MessageBox.Show(ec.Message);
}

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

Edited by __avd: added code tags.

5
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by thines01
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.