O
Oltmans
Hi All,
I'm trying to send an HTML email from my asp.net 2.0 application. I
want to show an "alert" message when user opens up my email message
using JavaScript. Though I've been able to send email but I am
*unable* to show an alert message using JavaScript. Any ideas, please
enlighten me. Thanks.
Here is my code
--------------------------
SmtpClient smtpClient = new SmtpClient();
MailMessage objMail = new MailMessage();
//From Address will be assigned from the e-mail specified
in the From TextField
MailAddress objMail_fromaddress = new
MailAddress("(e-mail address removed)");
//To Address will be assigned from the e-mail specified in
the To TextField
MailAddress objMail_toaddress = new
MailAddress("(e-mail address removed)");
//Assigning From address to the MailMessage class
objMail.From = objMail_fromaddress;
//Assigning To address to the MailMessage class as a
collection
objMail.To.Add(objMail_toaddress);
objMail.Subject = ".NET email";
StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.Append("<head>");
sb.Append("<script type=\"text/javascript\">");
sb.Append("window.onload=hello;");
sb.Append("function hello(){alert(\"Hi there, What's up
\");}");
sb.Append("</head>");
sb.Append("<body>");
sb.Append("<form><br/>");
sb.Append("<input type=\"text\" id=\"tb\" /></form>");
sb.Append("</body>");
sb.Append("</html>");
objMail.IsBodyHtml = true;
objMail.Body = sb.ToString();
objMail.Priority = MailPriority.High;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new
System.Net.NetworkCredential("(e-mail address removed)", "mypassword");
try
{
smtpClient.Send(objMail);
//HttpContext.Current.Response.Redirect("http://
localhost");
}
catch (Exception exc)
{
HttpContext.Current.Response.Write("Send failure: " +
exc.ToString());
}
I'm trying to send an HTML email from my asp.net 2.0 application. I
want to show an "alert" message when user opens up my email message
using JavaScript. Though I've been able to send email but I am
*unable* to show an alert message using JavaScript. Any ideas, please
enlighten me. Thanks.
Here is my code
--------------------------
SmtpClient smtpClient = new SmtpClient();
MailMessage objMail = new MailMessage();
//From Address will be assigned from the e-mail specified
in the From TextField
MailAddress objMail_fromaddress = new
MailAddress("(e-mail address removed)");
//To Address will be assigned from the e-mail specified in
the To TextField
MailAddress objMail_toaddress = new
MailAddress("(e-mail address removed)");
//Assigning From address to the MailMessage class
objMail.From = objMail_fromaddress;
//Assigning To address to the MailMessage class as a
collection
objMail.To.Add(objMail_toaddress);
objMail.Subject = ".NET email";
StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.Append("<head>");
sb.Append("<script type=\"text/javascript\">");
sb.Append("window.onload=hello;");
sb.Append("function hello(){alert(\"Hi there, What's up
\");}");
sb.Append("</head>");
sb.Append("<body>");
sb.Append("<form><br/>");
sb.Append("<input type=\"text\" id=\"tb\" /></form>");
sb.Append("</body>");
sb.Append("</html>");
objMail.IsBodyHtml = true;
objMail.Body = sb.ToString();
objMail.Priority = MailPriority.High;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new
System.Net.NetworkCredential("(e-mail address removed)", "mypassword");
try
{
smtpClient.Send(objMail);
//HttpContext.Current.Response.Redirect("http://
localhost");
}
catch (Exception exc)
{
HttpContext.Current.Response.Write("Send failure: " +
exc.ToString());
}