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
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)
MS_Invoice_Link__c

I tried following the example provided on this link, but got lost. 
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_creating.htm

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
         <br/><br/>
         <c:yourComponentName ApplID="{!relatedTo.Id}"/>
     </messaging:htmlEmailBody>
</messaging:emailTemplate>

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}"/>
</apex:component>
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;
    }

}


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