<script type="text/javascript">
var numbers = [];
min = 0;
max = 100;
for (var i = min; numbersArray.push(i++) < max;);
// numbers = [0,1,2,3 ... 100]
</script>
The best resource for .NET Developers. This blog guides about .NET (C#.NET, ASP.NET, ASP.NET MVC, SQL Server, ADO.NET), AngularJS, JSON, HTML, JavaScript, jQuery, CSS, Bootstrap, DotNetNuke, and .NET interview questions. This blog teaches everything about the .NET. Here you can find bunch of tutorials, Tips and tricks, code samples and examples.
namespace SendMail
{
public partial class SendMail : System.Web.UI.Page
{
protected void btnSendEmail_Click(object sender, System.EventArgs e)
{
try
{
// retrive all the details from the page.
var fromAddress = txtFrom.Text;
var toAddress = txtTo.Text;
string fromPassword = txtPassword.Text;
string subject = txtSubject.Text;
string body = txtBody.Text;
// Create a new SMTP Client instance by passing the SMTP details.
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
//Send the email using the send method of the System.Net.Mail.SmtpClient
smtp.Send(fromAddress, toAddress, subject, body);
Response.Write("<script>alert('Mail Sent Successfully...')</script>");
}
catch (System.Net.Mail.SmtpException ex)
{
Response.Write("<script>alert('The username or password you entered is incorrect.')</script>");
}
catch (System.Exception ex)
{
Response.Write("<script>alert('"+ex.Message+"')</script>");
}
finally
{
ResetControls();
}
}
private void ResetControls()
{
txtFrom.Text = string.Empty;
txtTo.Text = string.Empty;
txtPassword.Text = string.Empty;
txtSubject.Text = string.Empty;
txtBody.Text = string.Empty;
}
}
}