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("abce@gmail.com");
//To Address will be assigned from the e-mail specified in
the To TextField
MailAddress objMail_toaddress = new
MailAddress("abc@live.com");
//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("abce@gmail.com", "mypassword");
try
{
smtpClient.Send(objMail);
//HttpContext.Current.Response.Redirect("http://
localhost");
}
catch (Exception exc)
{
HttpContext.Current.Response.Write("Send failure: " +
exc.ToString());
}
Alvin Bruney [MVP] - 07 Oct 2007 01:06 GMT
I'm not sure window.onload would work so you may have to try the body tag's
onload event

Signature
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$24.99
> Hi All,
>
[quoted text clipped - 65 lines]
> exc.ToString());
> }
Göran Andersson - 07 Oct 2007 02:24 GMT
> Hi All,
>
[quoted text clipped - 3 lines]
> *unable* to show an alert message using JavaScript. Any ideas, please
> enlighten me. Thanks.
I don't think that you can find any mail client that will support
Javascript in a mail.
You can use html format in a mail, but that doesn't turn the mail into a
web page, it's still just a mail message.

Signature
Göran Andersson
_____
http://www.guffa.com