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

Word attachments in visualforce email templates



I am trying to create a word file attachment in the visualforce email template. The code I use inside the template is as follows:


<messaging:attachment filename="{!}.doc" > 
    <html xmlns:v="urn:schemas-microsoft-com:vml"
    <meta name="contentType"
    <meta name="ProgId" content="Word.Document" />
    <meta name="Generator" content="Microsoft Word 12" />
    <meta name="Originator" content="Microsoft Word 12" />
<apex:repeat var="cx" value="{!relatedTo.ChildRelationName__r}">
<td> <apex:outputField value="{!cx.field1__c}"/> </td>
<td> <apex:outputField value="{!cx.field2__c}"/> </td>
<td> <apex:outputField value="{!cx.field3__c}"/> </td>




But the attached word file always shows error when I try to open it.


We could set the attribute contentType="application/msword" for apex:page, but I don't seem to find any such attribute for messagin:attachment.


I just wanted to know if anyone has done this? Any help is appreciated!!