Date parsed: 06/10/2007 16:06:55
Date: Sat, 6 Oct 2007 20:06:55 -0400
I'm not sure window.onload would work so you may have to try the body tag's
onload event
--
Regards,
Alvin Bruney
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on
www.lulu.com/owc$24.99
"Oltmans" <rolf.oltmans@gmail.com> wrote in message
news:1191671242.212777.313470@w3g2000hsg.googlegroups.com...
> 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());
> }
>