get and set opportunity from VF page to controller class. Lets say opportunity Id is 'opptyId', You can get all product Names by using following code -
List<OpportunityLineItem > lstOLI = [Select Id, OpportunityId, Name From OpportunityLineItem where Id =: opptyId]; List<String> productName = new List<String>(); for(OpportunityLineItem OLI : lstOLI){ productName.add(OLI.Name); }
get and set opportunity from VF page to controller class. Lets say opportunity Id is 'opptyId', You can get all product Names by using following code -
List<OpportunityLineItem > lstOLI = [Select Id, OpportunityId, Name From OpportunityLineItem where Id =: opptyId];
List<String> productName = new List<String>();
for(OpportunityLineItem OLI : lstOLI){
productName.add(OLI.Name);
}
Let me know if this works for you.
Regards,
Santosh Chitalkar
From EmailTemplate relatedTo you can get the Opportunity ID .
I think this will help you .