Link to home
Start Free TrialLog in
Avatar of David C
David CFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.NET chart not being embedded in email

Hi Experts,

I am using the code below to capture a pages HTML and send it in an email. The issue is I have introduced a ASP.NET chart but its not being sent in the email? Is there anything I need to do to the chart?

 Dim renderedOutput As StringBuilder
        Dim strWriter As StringWriter
        Dim tWriter As HtmlTextWriter
        Dim html As String

        'create a HtmlTextWriter to use for rendering the page
        renderedOutput = New StringBuilder
        strWriter = New StringWriter(renderedOutput)
        tWriter = New HtmlTextWriter(strWriter)
        'render the page output
        Page.RenderControl(tWriter)
        html = renderedOutput.ToString

        mail.Body = html

Open in new window

Avatar of ingriT
ingriT
Flag of Netherlands image

Are you using javascript (or jQuery) to create the chart? You can only send simple HTML in an e-mail.

You could try inserting the chart through an iFrame maybe.
Avatar of David C

ASKER

The chart is ASP.NET object that I just dragged from the toolbox and bound some data to it
Can you check the source of the result in a webpage? It will probably show javascript code to generate the chart.
Avatar of David C

ASKER

Thanks ingriT this is the URL
ChartImg.axd?i=chart_bb15068bc57f4be4b7e30d067ad0f705_0.png&g=eff92e323abd42879b4f7d1f7e618046

Open in new window


I am only assuming but I think this will be different everytime it runs. How would I access the generated path during runtime that way I can embedd that URL in the email and see if it opens
You could also create a webpage (ie. Chart.aspx) that only shows this chart, and that way, you can always link it to this page, and not the chart inside the page.
Avatar of David C

ASKER

That sounds like a great idea. How would I link the page? iFrame? or is there a better way
ASKER CERTIFIED SOLUTION
Avatar of David C
David C
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, an inline image is probably your best option, good luck!
Avatar of David C

ASKER

Found a cleaner solution to embed the chart image by saving the image first then embedding the image to the email.

Also added <td><img src="cid:IMAGE_ID"></td> to the source to location of chart.