473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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();
}
}
}
Jan 3 '21 #1
1 4142
BradmanDon
3 2Bits
Instead of Console.WriteLine(ex.ToString()) maybe try Console.WriteLine(ex.Message)
Mar 4 '21 #2

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

Similar topics

8
by: harry | last post by:
Hi, During compilation, a C# project in my solution triggers the following warning: "warning CS0168: The variable 'ex' is declared but never used" To trigger this warning, it appears the C#...
5
by: David | last post by:
I am having a bit of a problem with catching an exception within a thread. Here is the scenario: I have a Windows Form. I create a new thread. This new thread calls a method in another DLL...
7
by: Les Caudle | last post by:
If I have code such as: catch (WebException WebExcp) { return false; } I will get a warning CS0168: The variable 'WebExcp' is declared but never used when compiling.
2
by: hui | last post by:
Here is a problem I am having with web form designer. I have a database control in the form, and setup the connection string as a dynamic property. It compiles and runs fine. I close the aspx...
7
by: What-A-Tool | last post by:
In the following code, "catch" is underlined in blue, and the error "the variable fx is declared but never used" is displayed when I mouse hover over it. Am I doing something wrong, or do I just...
6
by: Jody Gelowitz | last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0...
17
by: cashdeskmac | last post by:
Nice and simple one for you all... Is there a time to use Catch(Exception) rather than creating an instance of the Exception, as in Catch(Exception ex)?
1
by: 22dude | last post by:
it says the variable hours is being used with out being initializes i am using C++ 2005 express edition , I am currently student Please help me out to find the solution on my code below #...
2
by: LivingJunk | last post by:
This is for a homework but i'm stuck trying to figure out my error. #include<stdlib.h> #include<math.h> int getData(FILE *input, float *arr, float *mean, float *sD); float **pointing(float...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.