2 Replies Latest reply on Aug 14, 2007 11:02 AM by ssawka

    Sending a chart via email

    shloime11
      Hi,
      Would anyone know if it is possible to generate a cfchart in an email? I tried and it would not show in the email. I tried with gmail and with MS Outlook.

      Below id the code I used:

      <cfmail to="abc@abc.com" from="abc@abc.com" subject="chart test" type="HTML">
      email start
      <cfchart
      xAxisTitle="Day"
      yAxisTitle="Visitors"
      font="Arial"
      gridlines=6
      showXGridlines="yes"
      showYGridlines="yes"
      showborder="yes"
      show3d="yes"
      chartHeight = "500"
      chartWidth = "700"
      XAxisType="date"
      >

      <cfchartseries type="bar" seriesColor="red" paintStyle="plain">
      <cfchartdata item="1" value="100">
      <cfchartdata item="2" value="200">
      <cfchartdata item="3" value="300">
      <cfchartdata item="4" value="250">
      </cfchartseries>
      </cfchart>
      email end
      </cfmail>
        • 1. Re: Sending a chart via email
          Level 7
          shloime11 wrote:
          > Hi,
          > Would anyone know if it is possible to generate a cfchart in an email?

          no, not possible.
          but you could:
          - first generate a jpeg-format chart and, using the NAME attribute of
          <cfchart> tag assign it to a variable instead of displaying the chart
          - use <cffile action="write" output="#yourcfchartvariablenamehere#"
          file="fullpathtoyourfilehere" addnewline="no"> to save it as a jpeg image,
          - and then attach that file to the email.
          --

          Azadi Saryev
          Sabai-dee.com
          http://www.sabai-dee.com
          • 2. Re: Sending a chart via email
            ssawka Level 1
            You can also embed it in the email using a bit of MIME trickery, although this is far more complicated, using the following steps:


            1. Generate the chart and give it a name so it is stored in a variable.
            2. Generate a UUID that you will use as a CID for the image in the email.
            3. Save the image to a temporary directory using the UUID as the filename.
            4. Write the HTML contents of the email and place an <img src=" the UUID"> where you want the chart to appear.
            5. Attach the file to the email
            6. Delete the temp file

            Something like: