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
IX Salesforce AdminIX Salesforce Admin 

Send email using a custom button

Hello,

we are trying to send an email using a custom button. The email is intended for a specific email address. This is the code we are using:
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var message = new sforce.SingleEmailMessage(); 

message.setToAddresses = 'test@test.com';
message.plainTextBody = 'It would be so awesome if this worked.';
message.setCcAddresses = 'test2@test.com';
message.setBccAddresses = 'test3@test.com';
message.setSubject = 'Data upload report';

var result = sforce.connection.sendEmail([message]); 
alert(result);

unfortunately this is the error message we are getting.

error

what are we doing wrong?


Thank you.
IX Salesforce AdminIX Salesforce Admin
I apologize, this is the code:
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}

var message = new sforce.SingleEmailMessage(); 

message.ToAddresses = 'test@test.com';
message.plainTextBody = 'It would be so awesome if this worked.';
message.CcAddresses = 'test2@test.com';
message.BccAddresses = 'test3@test.com';
message.Subject = 'Data upload report';

var result = sforce.connection.sendEmail([message]); 
alert(result);

 
Krishnamoorthi PeriasamyKrishnamoorthi Periasamy
https://success.salesforce.com/answers?id=90630000000gtNyAAI
Krishnamoorthi PeriasamyKrishnamoorthi Periasamy
or see this

http://salesforce.stackexchange.com/questions/78789/custom-button-to-send-an-email-using-email-template
IX Salesforce AdminIX Salesforce Admin
Hello Krishnamoorti,

thank you for the reply. Both examples are explaining how to use a template, I am trying to avoid this. Can't I simply define recepients, subject and body?