I added custom button from my case object inside, then i sent test mail its work but i want to use Html template, also i want to add my records from html templates for example "Hello Your Account Name "records[0].Account.Name" I couldnt took error message but Besides the i could took null mail

This is my Js Custom button code:

{!REQUIRESCRIPT ('soap/ajax/29.0/connection.js')} {!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')}

var result= sforce.connection.login("---------","-----------");

sforce.connection.sessionId = result.sessionId;

var Query = sforce.connection.query("Select Id,Owner.Name,Owner.Id,Product__c,Origin,Account.Name,AccountOwner__c,Arizali_Urun_Seri_Numarasi__c,Priority,Status,RecordType.Name From case where id = '{!Case.Id}'");

records = Query.getArray("records"); 


var singleRequest = new sforce.SingleEmailMessage();
singleRequest.senderDisplayName = "Developer";
singleRequest.toAddresses= ["furkankuyular@yahoo.com"];
singleRequest.subject = "Test";
singleRequest.targetObjectId= records[0].Owner.Id;
singleRequest.whatId = records[0].Id;
singleRequest.templateId = "00X1w000000Splc";
singleRequest.saveAsActivity = false;

var sendMailRes = sforce.connection.sendEmail([singleRequest]);


if(sendMailRes[0].success == 'true') { 
alert("Finally it worked!."); 
} else { 

This is my success Log SuccessLog

This is my mailbox Mailbox

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.