Embed HTML Table within E-mail body through CFMAIL

I would like to e-mail out a table that is embedded within the e-mail message and use CFMAIL to send it.  I can get the CFMAIL to send to the users, but I can't figure out how to embed the table of information into the body of the e-mail.  Here is the table I want to put in the e-mail body.


<TABLE border="1" bordercolor="black" style="TABLE {font-family:tahoma; font-size:10pt; }">
<FONT size=2>Click on Column Heading to sort</FONT>
<CFOUTPUT query="QUERY">
<TR>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=name">Contact Name</A></B></TD>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=Company">Company</A></B></TD>
      <TD width="150" align="left"><B><A href="page.cfm?username=#username#&orderby=email">E-Mail Address</A></B></TD>
      <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=phone">Phone Nbr</A></B></TD>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=code">Product Code</A></B></TD>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=type">Size</A></B></TD>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=grade">Grade</A></B></TD>
      <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=variety">Variety</A></B></TD>
      <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=label">Label</A></B></TD>
      <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=qty">Qty</A></B></TD>
      <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=price">Price</A></B></TD>
      <TD width="20" align="left"><B>Edit</B></TD>
      <TD width="20" align="left"><B>Delete</B></TD>
      </TR>
</CFOUTPUT>
<CFOUTPUT QUERY="Query">
      <TR>
      <TD width="200" align="left">#Name#</TD>
      <TD width="200" align="left">#Company#</TD>
      <TD width="100" align="left"><A href="mailto:#email#">#email#</A></TD>
      <TD width="75" align="left">#phone#</TD>
      <TD width="200" align="left">#code#</TD>
      <TD width="200" align="left">#type#</TD>
      <TD width="200" align="left">#grade#</TD>
      <TD width="200" align="left">#variety#</TD>
      <TD width="100" align="left">#label#</TD>
      <TD width="50" align="left">#qty#</TD>
      <TD width="50" align="left">#price#</TD>
      <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Edit</A></TD>
      <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Delete</A></TD>
      </TR>
      </CFOUTPUT>
</TABLE>

can this be done and if so how?  Thanks in advance
austintreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tacobell777Commented:
<cfmail to="email here" from="email here" subject="subject here" type="html" >
<cfmailpart type="html">
<TABLE border="1" bordercolor="black" style="TABLE {font-family:tahoma; font-size:10pt; }">
<FONT size=2>Click on Column Heading to sort</FONT>
<CFOUTPUT query="QUERY">
<TR>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=name">Contact Name</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=Company">Company</A></B></TD>
     <TD width="150" align="left"><B><A href="page.cfm?username=#username#&orderby=email">E-Mail Address</A></B></TD>
     <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=phone">Phone Nbr</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=code">Product Code</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=type">Size</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=grade">Grade</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=variety">Variety</A></B></TD>
     <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=label">Label</A></B></TD>
     <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=qty">Qty</A></B></TD>
     <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=price">Price</A></B></TD>
     <TD width="20" align="left"><B>Edit</B></TD>
     <TD width="20" align="left"><B>Delete</B></TD>
     </TR>
</CFOUTPUT>
<CFOUTPUT QUERY="Query">
     <TR>
     <TD width="200" align="left">#Name#</TD>
     <TD width="200" align="left">#Company#</TD>
     <TD width="100" align="left"><A href="mailto:#email#">#email#</A></TD>
     <TD width="75" align="left">#phone#</TD>
     <TD width="200" align="left">#code#</TD>
     <TD width="200" align="left">#type#</TD>
     <TD width="200" align="left">#grade#</TD>
     <TD width="200" align="left">#variety#</TD>
     <TD width="100" align="left">#label#</TD>
     <TD width="50" align="left">#qty#</TD>
     <TD width="50" align="left">#price#</TD>
     <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Edit</A></TD>
     <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Delete</A></TD>
     </TR>
     </CFOUTPUT>
</TABLE>
</cfmailpart>
<cfmailpart type="text">
text version here if you need it, otherwise delete this part
</cfmailpart>
</cfmail>
0
mrichmonCommented:
One change to tacobell'ss code :

Don't use cfoutput inside cfmail - instead use cfloop - more efficeint

ANd one comment on yours - why do you loop twice?  Shouldn't the header row only appear once?

 <cfmail to="email here" from="email here" subject="subject here" type="html" >
<cfmailpart type="html">
<TABLE border="1" bordercolor="black" style="TABLE {font-family:tahoma; font-size:10pt; }">
<FONT size=2>Click on Column Heading to sort</FONT>
<TR>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=name">Contact Name</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=Company">Company</A></B></TD>
     <TD width="150" align="left"><B><A href="page.cfm?username=#username#&orderby=email">E-Mail Address</A></B></TD>
     <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=phone">Phone Nbr</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=code">Product Code</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=type">Size</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=grade">Grade</A></B></TD>
     <TD width="200" align="left"><B><A href="page.cfm?username=#username#&orderby=variety">Variety</A></B></TD>
     <TD width="100" align="left"><B><A href="page.cfm?username=#username#&orderby=label">Label</A></B></TD>
     <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=qty">Qty</A></B></TD>
     <TD width="50" align="left"><B><A href="page.cfm?username=#username#&orderby=price">Price</A></B></TD>
     <TD width="20" align="left"><B>Edit</B></TD>
     <TD width="20" align="left"><B>Delete</B></TD>
     </TR>
<CFLOOP QUERY="Query">
     <TR>
     <TD width="200" align="left">#Name#</TD>
     <TD width="200" align="left">#Company#</TD>
     <TD width="100" align="left"><A href="mailto:#email#">#email#</A></TD>
     <TD width="75" align="left">#phone#</TD>
     <TD width="200" align="left">#code#</TD>
     <TD width="200" align="left">#type#</TD>
     <TD width="200" align="left">#grade#</TD>
     <TD width="200" align="left">#variety#</TD>
     <TD width="100" align="left">#label#</TD>
     <TD width="50" align="left">#qty#</TD>
     <TD width="50" align="left">#price#</TD>
     <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Edit</A></TD>
     <TD width="20" align="left"><A href="page.cfm?ID=#ID#&amp;username=#username#">Delete</A></TD>
     </TR>
     </CFLOOP>
</TABLE>
</cfmailpart>
<cfmailpart type="text">
text version here if you need it, otherwise delete this part
</cfmailpart>
</cfmail>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tacobell777Commented:
ok ok then.. ;-)

<style>
div#layout table
{
      border: 1px solid black;
      font-family: tahoma, Arial, Helvetica, sans-serif;
      font-size: 10px;
}
caption
{
      font-size: 200%;
}

th a
{
      font-weight: bold;
}
</style>

<div></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <caption>
  Click on Column Heading to sort
  </caption>
<thead>
  <tr>
    <th scope="col"><A href="page.cfm?username=#username#&orderby=name">Contact Name</A></th>
    <th scope="col"><A href="page.cfm?username=#username#&orderby=Company">Company</A></th>
    <th scope="col"><A href="page.cfm?username=#username#&orderby=email">E-Mail Address</A></th>
    <th scope="col">ETC.</th>
  </tr>
</thead>
<tbody>
<CFLOOP QUERY="Query">
  <tr>
    <td>#Query.Name#</td>
    <td>#Query.Company#</td>
    <td><A href="mailto:#Query.email#">#Query.email#</A></td>
    <td>ETC.</td>
  </tr>
</CFLOOP>
</tbody>
</table>

0
aftershoxCommented:
<CFSAVECONTENT Variable="EmailContent">
 .... your table code ....
</CFSAVECONTENT>

<CFMAIL to=".." from="..." subject="..." type="HTML">
#EmailContent#
</CFMAIL>
0
austintreAuthor Commented:
Ok, sorry I didn't get back to you until this morning, but mrichmon was correct and the easiest to use.  You cannot use CFOUTPUT within a CFMAIL tag.  However, CFLOOP worked.  So, hats off to mrichmon for giving me what I needed.  By the way your line <cfmailpart type="html">  does not work.  It didn't like it.  However, within your CFMAIL paramaters you specify the type.  So it should look like this:

<CFOUTPUT query="query" group="email">
    <CFMAIL TO="#email#"
            FROM="email@email.com"
            SUBJECT="subject line"
      TYPE="HTML"
      SERVER="mail.server.com"
      PORT="25">

Thank you for your comments.  I am going to study aftershox idea of CFSAVECONTENT  and tacobell your second idea went way over my head, but thanks for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.