4 Replies Latest reply on May 1, 2014 10:38 AM by BKBK

    Send email with HTML output?


      I have A CFM FILE(testing3.cfm):


      <cfset month = #URL.Month#>
      <cfset year = #URL.Year#>
      SELECT .....code..
      <tr >
      <th>Employee First Name</th>
      <th>Employee Last Name</th>
      <cfoutput query="">
      <tr >
      --- more code, pretty much the same

      I can see this 'report' when i click on the link depending on the year or month.(testing2.cfm) file



      This file gets data from a table from every month,

      which works good.

      I want to be able to send a email of these results to who ever I choose to send it to.

      For example not the same people everytime , I would choose who I put in the 'TO' email part.

      So maybe there would be a button/link that would open up the email message (outlook) and i

      be able to see what is on  the html and be able to send it to the people I would like.

      Doing my research I have seen I can use 'cfemail' but this doesnt seem like it would be able

      to do what I want, only be able to do attachments.I would like to see the report i will send

      before I send it out( from the above code i can click on it).

      I be thinking maybe I can add a button/link next the the month in 'testing2.cfm', but im not sure if

      that would be the best way to do it.

      What would be the best way I can approch this? Any tips or articles I can read would help.

        • 1. Re: Send email with HTML output?
          WolfShade Level 4

          Everything between your HTML tags can go inside a <cfmail> tag.  You can do the CFSET stuff prior to the CFMAIL tag.


          BTW.. unless a variable is being used within a string, you don't need hashes.


          <cfset month = #URL.Month#> should be <cfset month = URL.Month>





          • 2. Re: Send email with HTML output?
            no_name_123 Level 1

            If i do it that way wouldnt that send it a email everytime i click on the link?

            • 3. Re: Send email with HTML output?
              WolfShade Level 4

              Precisely.  If you want to view the data before sending the email, create a second page that uses the CFMAIL tag and put a link to it on the first.



              • 4. Re: Send email with HTML output?
                BKBK Adobe Community Professional & MVP

                You could design it such as to be able to view the content and send the mail on the same page. An example follows.



                1/2014 (a link that takes you to testing3.cfm)



                <cfsavecontent variable="pageContent">







                <tr >


                <th>Employee First Name</th>

                <th>Employee Last Name</th>








                <!--- Display page content --->





                <!--- Clicking on this link will re-open the current page, and send mail --->

                <a href="testing3.cfm?action=mail">Send mail</a>



                <cfif isdefined("URL.action") and URL.action is "mail">

                    <cfquery name="getEmailAddresses" datasource="myDSN">

                        SELECT email FROM myTable



                    <cfmail query="getEmailAddresses"





                Dear colleague,


                Here is the information for January 2014.







                <p>The e-mails have been sent!</p>