1

i need this page as word document,content type="application/word" is not supporting here.this is my code

<messaging:emailTemplate subject="Test Email"  relatedToType="Invention_Disclosure_New__c">
<messaging:attachment renderAs="PDF" filename="{!relatedTo.Title__c}_Invention Disclosure questionaire.pdf">
<html>
    <head/>
    <body>
        <div>What is the invention? What are features of the invention and how do they solve the problem? Describe your implementation(s) of the invention using examples. (Tip: describe your invention as thoroughly as possible so that the reader can use this description to build the system that solves the problem.)
        </div>
            <div>{!relatedTo.Detailed_Description__c}</div>

    </body>
</html>
</messaging:attachment>
1
  • 1
    if the below answer was helpful, remember to mark it as accepted, thanks
    – glls
    Apr 11, 2018 at 17:34

1 Answer 1

3

According to this: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_messaging_attachment.htm the renderAs works with any valid mime type/sub-type https://www.freeformatter.com/mime-types-list.html

so theoreticxally, changing the renderAs to: application/vnd.openxmlformats-officedocument.wordprocessingml.document should cause it to attach as a .docx file. While you may not get an error if you try to use this mime type; a .docx file is virtually a zip file and you can't define all the necessary components so you will always get an error when trying to open it.

<messaging:attachment renderAs="application/vnd.openxmlformats-officedocument.wordprocessingml.document" filename="{!relatedTo.Title__c}_Invention Disclosure questionaire.pdf">

You can use application/msword for the older generic word .doc format

Make sure your filename ends with the correct extension as well. So change the render as and then change the filename to use .doc Instead of .pdf.

4
  • i have used like this,<messaging:attachment renderAs="application/msword" filename="{!relatedTo.Title__c}_Invention Disclosure questionaire.docx"> downloading as word doc but content not opening,saying problem on opening content
    – Elango
    Apr 11, 2018 at 16:07
  • That's because, as I said in my answer, that application/msword is .doc, NOT .docx. The .docx file is the really long one I posted. That being said, I just finished testing and you don't want to use .docx cause you'll always get that error (.docx is basically a zip of multiple files, there's not really a way to build that out in an email template like this). So, change your file extension to .doc and you'll be fine (I just tested and had no issues)
    – gNerb
    Apr 11, 2018 at 16:11
  • thanks,its working fine.<messaging:attachment renderAs="application/msword" filename="{!relatedTo.Title__c}_Invention Disclosure questionaire.doc">
    – Elango
    Apr 11, 2018 at 16:33
  • If its working please remember to mark this as the acceptable answer to help future users who have the same question
    – gNerb
    Apr 11, 2018 at 16:37

You must log in to answer this question.

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