I have created a custom button on Opportunity. The custom button has following javascript code. When the user clicks on the button the email should be sent.I find no errors in the code. But I am not able to send any emails.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
(function() {
sforce.connection.sessionId = "{!$Api.Session_ID}";
var message = new sforce.SingleEmailMessage();
message.replyTo = "varunreddypenna@gmail.com,varunrp@okstate.edu";
message.targetObjectId = "{!Opportunity.Id}";
message.templateId = "00Xj0000000J8sI";
var result = sforce.connection.sendEmail([message]);
if(result[0].success) {
alert("I sent the email as you requested, master.");
} else {
alert("I had a booboo.");
}
}());