i have error message (Failure sending mail)
in public class i have this code to send message:
public static bool sendMail(string subject, string msg, string to)
{
MailMessage mmsg = new MailMessage("wolf@gmail.com", to, subject, msg);
mmsg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.UseDefaultCredentials = false;
NetworkCredential cre = new NetworkCredential("wolf1@gmail.com", "yourPass");
client.Credentials = cre;
client.EnableSsl = true;
try
{
client.Send(mmsg);
return true;
}
catch
{
return false;
}
}
in another class i have a method
in my class called member i have two methods
private void initialize(CommandType CT,string DBcall)
{
conn = new SqlConnection();
cmd = new SqlCommand();
conn.ConnectionString = ConfigurationManager.ConnectionStrings[1].ToString();
cmd.Connection = conn;
cmd.CommandType =CT ;
cmd.CommandText = DBcall;
conn.Open();
}
public DataTable runQuery(string select)
{
initialize(CommandType.Text, select);
tbl = new DataTable();
tbl.Load(cmd.ExecuteReader());
conn.Close();
return tbl;
}
in class call member i have method :
public string getEmail(string userName)
{
try
{
return dbVar.runQuery("select email from members where userName= '" + userName + "' ").Rows[0][0].ToString();
}
catch
{
return "";
}
}
In may page i have wizard control when i double click in it i call above class code
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
member m=new member();
if (utility.sendMail("leader order ", lblMessage.Text, m.getEmail(c.UserName)))
lblMessage.Text += "email sent to conformation ,to your email ";
else
lblMessage.Text += "email not sent :" + m.getEmail(c.UserName);