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
ARUL BERNARD I 6ARUL BERNARD I 6 

How to send email to Contact Roles in opportunity object using custom link button

 I have created the following javascript code but still in error 

{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}

var emailAddresses = '';
var template_name = 'Congrz Mail';

var customRecord = sforce.connection.query("SELECT id,contact.Email FROM OpportunityContactRole WHERE Id ='"+ '{!Opportunity.Id}'
+"'");

emailAddresses = customRecord.records.Email;

var email_template = sforce.connection.query("SELECT id FROM EmailTemplate WHERE name ='"+ template_name+"'");

var templateid= email_template.records.Id;

location.replace('/email/author/emailauthor.jsp?&p24={!customRecord .Email}&template_id=00X6F000001Ge1kUAC&p3={!customRecord .Name}&p26={!customRecord .Email}&p2={!customRecord .Id}');