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
Lukesh KarmoreLukesh Karmore 

receiving an empty email body after merging fields

i merge below  fields,but not receive in email
Hii,{!Contact.Name}
Your Order has been proceed
Your order detail is below.
Product Name:{!Product2.Name}
Product Code:{!Product2.code}
Unit Price:{!OpportunityLineItem.UnitPrice}
List Price:{!OpportunityLineItem.ListPrice}
Discount:{!OpportunityLineItem.Discount}
Thanks
{!Contact.Name}


User-added image
Vishwajeet kumarVishwajeet kumar
Hello,
Looks like related to record is not getting set while sending the email. Try to test it from email template by selecting sample 'Related To' records.

Thanks
Lukesh KarmoreLukesh Karmore
already checked it but not worked
sreenath reddy 21sreenath reddy 21
Hi lukesh 
Can you send the complete, i will check where it is failed
 
Lukesh KarmoreLukesh Karmore
my Trigger code is:
and above image is ,email i received and merge fields:
you can checked it:

trigger question13 on OpportunityLineItem (after  insert) {
set<id> myid=new set<id>();
    for(OpportunityLineItem  oli:Trigger.new){
myId.add(oli.OpportunityId);
}
list<opportunity> opplist=[select id,account.name,account.Id,Account.clientcontact__c from opportunity where id in: myid];
list<Messaging.SingleEmailMessage> msglist=new list<Messaging.SingleEmailMessage>();
for(OpportunityLineItem  opp: Trigger.new){
for(opportunity myopp:opplist){
    Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    EmailTemplate templist=[SELECT Id, DeveloperName,subject,body FROM EmailTemplate WHERE DeveloperName='question_13_trigger2' limit 1];
    message.setTemplateId(templist.Id);
    message.setTargetObjectId(myopp.Account.clientcontact__c); 
   
    msglist.add(message);
}  
}
if(!msglist.isEmpty()){
    Messaging.sendEmail(msglist);
}
}1