+ Start a Discussion
Swapna MistrySwapna Mistry 

Visualforce email template

Hi everyone, 

Point and click Admin here. Hoping someone can help me with a visual force template. 

We've got a custom object called Case MS which is a child of Case.

I am trying to create a template that can be sent from the Case that lists all associated Case MS records. Fields needed:
Master_Shipment__c (This field is an External Lookup)

I tried following the example provided on this link, but got lost. 

Any help is greatly appreciated! Thank you!!
Lalit Karamchandani 27Lalit Karamchandani 27
Hi Swapna Mistry its just a example how to use vf email template and show custome object data in vf email template

Visual force Email template
<messaging:emailTemplate subject="Write here your email subjtect" recipientType="Contact" relatedToType="yourObject api name">
     <messaging:htmlEmailBody >
         Write message
         <c:yourComponentName ApplID="{!relatedTo.Id}"/>

Component code
<apex:component access="global" controller="yourComponentController" allowDML="true">
   <apex:attribute id="appIdZ" assignTo="{!appVIdZ}" name="ApplID" type="Id" description="what ever description you want "/>
   <apex:outputText escape="false"  value="{!AppMethod}"/>
Controller Code
public class yourComponentController {

    public Id appVIdZ{get;set;}
    public  yourComponentController(){
		don't write code in controller because that code not call in visual force email template 
		write code in get method only
	public String getAppMethod() {
        String remarkData;
        write code here like what ever you want to show in vf template 
        return remarkData;


Thanks Lalit, I had a similar issue posted in another thread and your solution helped me :)