embed HTML table using VB

A

Aur_Ros

I am showing a table in a web page, I need help to email this table,
please any sugestion ....? thanks!!
 
J

John Timney \(MVP\)

Sending html emails is as simple as the code below:

<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%
MailMessage msgMail = new MailMessage();
msgMail.To = "blah";
msgMail.Cc = "blah blah";
msgMail.From = "blah";
msgMail.Subject = "the subject text";

msgMail.BodyFormat = MailFormat.Html;
string strBody = "<html><body><b>Hello World</b>" + " <font
color=\"red\">ASP.NET</font></body></html>";
msgMail.Body = strBody;

SmtpMail.Send(msgMail);

%>

If your table however is within an asp.net page you'll have to acquire it as
a string that can be included as the html body of the mail. I would suggest
you take a read of this little snippet by Rick Strahl that explians
capturing output from a rendered web page.

http://www.johntimney.com/home/redir.aspx?=http://west-wind.com/weblog/posts/481.aspx

You'll then need to work out how to pick out your table if thats all you
require.

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 
A

Aur_Ros

thanks a lot John!!, yes that is what I need to do, I need to Know how
to get HTML code of that table created dynamically in the web page !!
 
J

John Timney \(MVP\)

The easiest way is usually to mark the table, by surrounding it with custom
tags !<--tablestarts-> !<--tableends-> then crop the string captured in the
render event using ther .net string methods.

or if yor doing it client side then wrap your table with a specific div
identifier and use javascripts innerHTML method and then post it to a page
that will invoke your mail method.

<div id= "myTable">This is my table.</div>

something like : document.getElementId("myTable").innerHTML .

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top