Does any one have tutorial on how can I send visualforce page as body of the email template?

  • 3
    Hi Kavya, welcome to SFSE! Your question is asking for other people to write code for you, without presenting a real question or issue. SFSE is a Q&A forum where we look to help each other by asking and answering questions that are real problems or errors. If you need assistance learning the Salesforce technical environment, visit developer.salesforce.com/docs for resources. – crmprogdev Apr 4 '15 at 12:40
  • Hi @crmprogdev - I am new to Salesforce and I have referred docs .. I need to know if implementing my query is possible .. and if there are tutorials available on it – Kavya Krishna Apr 4 '15 at 14:33
  • Tutorials and workbooks that teach the fundamentals of how to do many things with Salesforce that you're asking about are available from the link I provided you with. – crmprogdev Apr 4 '15 at 16:11

For sending the Visual force page content as email body, you need to make use of VF Email template in the Email alert and Apex component.

Basically, you need to create a Apex custom component, and use that in the Visualforce Email template, so that you can send the content in the VF page as email body, along with other static contents if needed.

Please refer below links for more details on using Apex component with VF Email templates :

Apex Component

Using Custom Component with VF Email template


You should render your visualforce page as a PDF and then you can have a button to send the document. This post may help you. Rendering a VF page as PDF and saving it as an attachement

  • What does mail.setTemplateID(templateId.Id); do ? – Kavya Krishna Apr 4 '15 at 12:04
  • Templateid is the ID of the template to be merged to create the email. Why not create a merge template and a custom button on your standard detail page? When the user clicks the button, you can redirect to the standard email page. You can even default the template and the recipient. I have a custom button in my org that does such. Something like this: location.replace('_ui/core/email/author/EmailAuthor?p2_lkid={!Contact.Id}&rtype=003&&p3_lkid={!Account.Id}&doc_id=015U0000002AU2x&retURL=/{!Contact.Id}&template_id=00XU0000000JQmE&p26={!$User.Email}') – Berg Apr 4 '15 at 12:12
  • Hi.. the user in this case will not have salesforce access.. and the email content needs to be sent in gmail / yahoo – Kavya Krishna Apr 4 '15 at 14:29
  • I need to send visualforce content into gmail or yahoo as email body – Kavya Krishna Apr 4 '15 at 14:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.