locked
SmtpClient.Send(Msg) not working in somee.com RRS feed

  • Question

  • User-802665341 posted

    if (ds.Tables[0].Rows.Count > 0)
    {
    MailMessage Msg = new MailMessage();
    // Sender e-mail address.
    Msg.From = new MailAddress("vikasparmar88@gmail.com");
    // Recipient e-mail address.
    Msg.To.Add(Temail.Text);
    Msg.Subject = "Check Password";
    Msg.Body = "Hi, <br/>Please check your Login Detailss<br/><br/>Your Username: " + ds.Tables[0].Rows[0]["Name"] + "<br/><br/>Your Password: " + ds.Tables[0].Rows[0]["Password"] + "<br/><br/>";
    Msg.IsBodyHtml = true;
    // your remote SMTP server IP.
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";
    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("vikasparmar88@gmail.com", "vijaydas@1991");
    smtp.EnableSsl = true;


    smtp.Send(Msg); ////////////// Redirects to Error page. I don't know what is wrong

    error.ForeColor = Color.Green;
    //Msg = null;
    error.Text = "Your Password Details Sent to your mail";
    // Clear the textbox valuess
    Temail.Text = "";
    }
    else
    {
    error.ForeColor = Color.Red;
    error.Text = "The Email you entered not exists.";
    }

    Monday, August 4, 2014 9:07 AM

Answers

  • User-1345528502 posted

    Hi,

    Put your error code : smtp.Send(Msg); inside TRY Block and see the error catches .

    Let us know if you get more trouble still

    Rigin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 6, 2014 6:06 AM

All replies

  • User197322208 posted

    and what is not working, precisely?

    Monday, August 4, 2014 10:15 AM
  • User-1345528502 posted

    Hi,

    Put your error code : smtp.Send(Msg); inside TRY Block and see the error catches .

    Let us know if you get more trouble still

    Rigin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 6, 2014 6:06 AM