Avatar of David C
David C
Flag 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

ASP.NET

Avatar of undefined
Last Comment
David C

8/22/2022 - Mon
ingriT

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.
David C

ASKER
The chart is ASP.NET object that I just dragged from the toolbox and bound some data to it
ingriT

Can you check the source of the result in a webpage? It will probably show javascript code to generate the chart.
Your help has saved me hundreds of hours of internet surfing.
fblack61
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
ingriT

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.
David C

ASKER
That sounds like a great idea. How would I link the page? iFrame? or is there a better way
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
David C

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ingriT

Yes, an inline image is probably your best option, good luck!
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.