Embedding a Googe Chart within an email

7,781 views
Skip to first unread message

superdave

unread,
Jan 27, 2009, 11:12:18 AM1/27/09
to Google Chart API
I need to distribute a chart generated by Google Charts within an
email. I've gotten it to generate or create the Google Charts link,
but want the actual chart to show within the email without having to
click on the link.

Can I do that relatively easy or am I going to need another app or api
to do that?

Thanks all,
Dave

James Scrimshire

unread,
Jan 27, 2009, 11:23:52 AM1/27/09
to google-c...@googlegroups.com
Just mail the image you get back.

KeithB

unread,
Jan 27, 2009, 11:24:49 AM1/27/09
to Google Chart API
A specific answer will depend on what component you're using to send e-
mails, but regardless of the component you should be able to specify
an HTML mode or an HTML body within which you can place a regular IMG
tag with a SRC attribute pointing to http://chart.apis.google.com/.

For example, using CDO.Message I would specify:

Dim signupEmail
Set signupEmail = Server.CreateObject("CDO.Message")
signupEmail.From = "..."
signupEmail.To = "..."
signupEmail.Subject = "..."
signupEmail.HTMLBody = "Google Chart Test <img src=...... />"
signupEmail.Send()

Good luck,
K

KeithB

unread,
Jan 27, 2009, 11:30:06 AM1/27/09
to Google Chart API
To different answers to the same question...

James' response refers to you manually sending the image via Microsoft
Outlook or Windows Mail or even Google Mail. Request the chart within
your browser, right click on the image and save it to your computer
and then attach that image within your e-mail.

My first response assumed that you wanted to generate a chart an
included it (programmatically) within an e-mail auto-generated by an
application or a form submission, etc.

Cheers,
K

superdave

unread,
Jan 27, 2009, 11:49:43 AM1/27/09
to Google Chart API
I'm basically using PowerShell to generate the Exchange Data, and
dynamically creating the HTTP Google Chart URL (kind of a daily
distro). This is a snipit of my current code... but it simply places
the URL link in the email... or if I use <img src='http://
googlechart.com' />... all I get is the text, no image. Am I doing
something wrong so the HTML coding is not working? Do I need to
specifiy HTML somewhere?

...
$pie_chart = "http://chart.apis.google.com/chart?
cht=p3&chs=365x150&chds=0," + $lval + "&chd=t:" + $valueBlock +
"&chl=" + "Exchange Data" + "&chco=0000ff,00ff00,ff0000,FFFFFF,000000"

$FromAddress = "Mailbo...@company.com"
$ToAddress = "ExchangeRepo...@company.com"
$MessageSubject = "Google Charts - EXCHSVR01"
$MessageBody = "
EXCHSVR01 Pie Chart
$pie_chart
<img src=$pie_chart />
"
$SendingServer = "EXCHSVR01.corp.local"
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress,
$ToAddress,
$MessageSubject, $MessageBody
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

THANKS!

KeithB

unread,
Jan 27, 2009, 11:57:48 AM1/27/09
to Google Chart API
It looks like there might be an "IsHtmlBody" parameter that you can
set to True (boolean).

Possibly $SMTPMessage.IsHtmlBody = ____


In addition, I forgot to add that you'll want to specify a full page
of HTML in your body.

$MessageBody = "<html><body><h2>EXCHSVR01 Pie Chart</h2><p><img
src=......... /></p></body></html>"


Hope that helps,
K

On Jan 27, 11:49 am, superdave <david.cunning...@gmail.com> wrote:
> I'm basically using PowerShell to generate the Exchange Data, and
> dynamically creating the HTTP Google Chart URL (kind of a daily
> distro).  This is a snipit of my current code... but it simply places
> the URL link in the email... or if I use <img src='http://
> googlechart.com' />... all I get is the text, no image.  Am I doing
> something wrong so the HTML coding is not working? Do I need to
> specifiy HTML somewhere?
>
> ...
> $pie_chart = "http://chart.apis.google.com/chart?
> cht=p3&chs=365x150&chds=0," + $lval + "&chd=t:" + $valueBlock +
> "&chl=" + "Exchange Data" + "&chco=0000ff,00ff00,ff0000,FFFFFF,000000"
>
> $FromAddress = "MailboxRep...@company.com"
> $ToAddress = "ExchangeReportRecipie...@company.com"

Mike Glen

unread,
Jan 27, 2009, 12:05:25 PM1/27/09
to google-c...@googlegroups.com
It is also worth noting that most modern email clients do not display
images from img tags by default when you open an email
(you normally have a load images button)

You can get round this by send the image as an attachment to the email
and you can then reference the attached image using an img tag in the
email body.

eg <img src="cid:attachedgraph.gif">
--
MINDsweep
25 albany street
edinburgh - UK - eh1 3qn

m: 07786984428


MINDsweep www.mindsweep.net is a division of c2sky services limited
www.c2sky.net

This e-mail may contain confidential information. It is intended solely
for the attention of the designated recipient(s). If you are not the
intended recipient, you must not make any use of the information
contained in the e-mail or cause or allow anyone to do so. Please
contact the sender immediately and delete the message.


James Scrimshire

unread,
Jan 27, 2009, 12:24:16 PM1/27/09
to google-c...@googlegroups.com
I had questioned whether he wanted a dynamic version, but plumper for
the simple answer. That's me all over

superdave

unread,
Jan 27, 2009, 2:02:10 PM1/27/09
to Google Chart API
No matter what I do, I can't get it to recognize the $MessageBody as
HTML, or more accurately to get the email (or client) to show the
email as HTML.

I've included all kind of <HTML> tags and such, but do not know SMTP
enough to know how to indicate it's HTML code as opposed to email code
(or something).

James, dynamic version? This HTML bit is dynamically generated via
the script, if that's what you meant.

Thanks,
Dave


On Jan 27, 12:24 pm, James Scrimshire <jascrimsh...@gmail.com> wrote:
> I had questioned whether he wanted a dynamic version, but plumper for  
> the simple answer. That's me all over
>

James Scrimshire

unread,
Jan 27, 2009, 2:06:49 PM1/27/09
to google-c...@googlegroups.com


I'll have a play around later and see if I can replicate your problem

KeithB

unread,
Jan 27, 2009, 2:16:33 PM1/27/09
to Google Chart API
Searching on different forms of the phrase
"System.Net.Mail.MailMessage send as html" returned some pages that
might help you.

I saw some sample code using an "AlternateView" property and some
using "MailMessage.IsBodyHtml = True

Good luck,
K

superdave

unread,
Jan 27, 2009, 2:21:41 PM1/27/09
to Google Chart API
I've tried using the Mailmessage.ishtmlbody = true, but got errors.
Could you post the links to the other posts?

Thanks,
Dave

Keith Bornhorst

unread,
Jan 27, 2009, 2:26:52 PM1/27/09
to google-c...@googlegroups.com

superdave

unread,
Jan 27, 2009, 3:13:30 PM1/27/09
to Google Chart API
BINGO!

$MailMessage.IsBodyHtml

The other posts I've seen all list it as $MailMessage.IsHtmlBody, and
it should be .IsBodyHtml.

Once I swapped it, it worked like I need it to!

And thank you Keith for the BrokenHaze link, that's where I got the
fix... at the bottom of that link is a post indicating the mistype
(right after the blog and rather hard to see). Thanks.

Dave



On Jan 27, 2:26 pm, Keith Bornhorst <kbornho...@gmail.com> wrote:
> http://www.google.com/search?hl=en&q=System.Net.Mail.MailMessage+powe...
>
> http://www.brokenhaze.com/article.php?story=20080228214713878
>
> http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.b...

Murali santosh kumar

unread,
Jul 3, 2015, 2:48:23 PM7/3/15
to google-c...@googlegroups.com, david.cu...@gmail.com
Hello All,

Can I able to generate the google charts for my Marketing automation tool reports and send the charts to bulk number of people through Marketing automation tool.

Please, Just give me a brief answer to this or suggest me any reference links 

Daniel LaLiberte

unread,
Jul 4, 2015, 2:40:55 PM7/4/15
to google-c...@googlegroups.com, david.cu...@gmail.com
Assuming you are trying to draw one of the corecharts or GeoChart, you'll probably want to generate an image for the chart and send that in the email.  See https://developers.google.com/chart/interactive/docs/printing

But how you get that image into an email will require additional work on your server-side.  Google Charts only runs on the client side, but emails can only be generated by a server, so you would have to generate the image in a browser, and then send the image URL back to the server so it could then send it out in an email.  

Hope that helps.

--
You received this message because you are subscribed to the Google Groups "Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chart-a...@googlegroups.com.
To post to this group, send email to google-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
Message has been deleted
0 new messages