On a custom object, I have a file storing a Google Docs file id.

With the URL, I can download the HTML code of the doc :


I'd like to attach this HTML code in a visualforce email with :

<messaging:attachment filename="{!relatedTo.Name}.pdf" renderAs="PDF">

<iframe src="https://docs.google.com/document/d/ID/export?format=html"></iframe>


But my attachment is empty.

How can I do ?

  • 1
    Is the doc public? Are you able to access the url it in incognito mode/without google login? Commented Jun 14, 2018 at 14:33
  • Yes, with the URL in a private browser, the HTML file is downloaded successfully.
    – Apaachee
    Commented Jun 14, 2018 at 14:44

1 Answer 1


This page seems to suggest that Iframes don't work in email.

What you could try to do is make a callout in your controller to get the HTML response and render the HTML response into the email via apex prior to sending it so that it's not nested within an iFrame tag.

public class HTMLController {

    public String Body {get; set;}

    public HTMLController(){
        HttpRequest req = new HttpRequest();

        Http http = new Http();
        HttpResponse resp = Http.send(req);

        this.Body = resp.getBody();

Then in the output:

<apex:component controller="HTMLController" access="global">
  <apex:outputText value="{!Body}" escape="false"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .