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
kartik_salesforcekartik_salesforce 

Need to generate document(.doc) from VF Page having contents of HTML Email template (with merge fields ,having image in Letterhead)

Hi All

we have email template in -- Communication Templates-->Email Templates (HTML Type template having image in letterhead) and placeholdr field like {!Account.Name}  

Technically we need to download HTML Type templates from VF Page after button click on a word .doc

Contents of our generate document VF Page

<apex:page controller="PCDMassEmailMailMergeController_Total" cache="true" contentType="application/MSWord#MassMail_{!segDocName}_{!uniqueIDmassemail}.doc" >
<html xmlns:w="urn:schemas-microsoft-com:office:word">

<apex:outputText escape="false"/>
<body>

<pre><b><apex:outputtext value="{!chosenEmailTemplateVal.Name}" escape="false"/>_Subject:<apex:outputtext value="{!chosenEmailTemplateVal.Subject}" escape="false"/></b></pre>
<pre><apex:outputtext value="{!chosenEmailTemplateVal.Body}" escape="true"/></pre>
<!--<pre><apex:outputtext value="{!chosenEmailTemplateVal.HtmlValue}" escape="true"/></pre>--> (this option works well for SFDC Preview but not in generate doc)
<apex:outputtext value="{!mailHtmlBody}" escape="false"/>
<apex:outputtext value="{!blobType}" escape="false"/>
<apex:outputtext value="{!test}" escape="false"/>
</body>
</html>
</apex:page>

Regards
Kartik
kartik_salesforcekartik_salesforce
for some Reason this code   does not bring the characters given below in a .doc file

{!Account.Name}
{!Account.Id}
{!Account.Phone}


but they appear when we make the following change to the below characters


{'!'Account.Name} or {\!Account.Name}
{'!'Account.Id} or {\!Account.Id}
{'!'Account.Phone} or {\!Account.Phone}

so is there a problem with the two characters next to each other which are {!

pls let me know

Thanks
Kartik

monikabhardwaj83monikabhardwaj83
Hi Kartik,

Did your problem got resolved? If yes then can you please share the code. I am also stuck in samescenario and not able to use email-template merge fields in a PDF .