function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Saving a external image as an attachment


I am trying to save a Google chart (PNG file) that I am displaying with a formula as an  attachment to my sObject. Its working fine as a HTML file, but I like to save the actual png file instead. Here is what I have:


my formula field DemoImage2:


IMAGE(",40&cht=p3&chl=Hello|World", "DemoImage2")


apex code:


Attachment a = new Attachment( parentId =, name=chgCotr.Name+'.html', body = Blob.valueof(chgCotr.DemoImage2__c ); Database.insert(a);



produces an html attachment with the following markup:


<img src=";chd=t:60,40&amp;cht=p3&amp;chl=Hello|World" alt="DemoImage2" border="0"/>


What I want to save is the source image as png file instead of the <img>markup.


How can I get this accomplished?


Thanks in advance for your suggestions.



Abdulla d 5Abdulla d 5

Hi Matt,
If u got the solution, please post it,

i'm also stuck in the same,