467,074 Members | 925 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

catch (Exception ex) -The variable 'ex' is declared but never used.

Bit
Also I am getting error in this 2nd line.
imagePictureBox.Image.Save(@path1, ImageFormat.Png);
please help me to find out what is missing

CODE :

private void button2_Click(object sender, EventArgs e)
{
string path1 = @"D:\1.Png";
imagePictureBox.Image.Save(@path1, ImageFormat.Png);
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("mythiliselvam13@gmail.com");
mail.To.Add(textBox1.Text);
mail.Subject = "Test Mail - 1";
mail.Body = "Data";

System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(path1);
mail.Attachments.Add(attachment);

SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("mythiliselvam13@gmai l.com","Success2021");
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);
MessageBox.Show("mail Sent");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}

private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
{
Login l = new WindowsFormsApplication1.Login();
l.Show();
this.Close();
}
}
}
1 Week Ago #1
  • viewed: 614
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by David | last post: by
7 posts views Thread by What-A-Tool | last post: by
17 posts views Thread by cashdeskmac | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.