How to send email from Snippet ?

Hi All,

How to send emails through SNIPPET?, like Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); in salesforce.

Here I need to send HTML template, my code like this:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();        mail.setTargetObjectId(NewContact.Id);  
mail.setTemplateId(‘00XD00000024V1F’);     //HTML Template
mail.setOrgWideEmailAddressId(emailAddress.Id); // Email Address to send
mail.setWhatId(nominationId);   // this
Messaging.sendEmail(new Messaging.SingleEmailMessage { mail });


Please help me out.


Thank you
Shaik.

Sorry.  You can’t put Apex in your Javascript. 

You make a remoting call from your Javascript to an Apex function.  That is detailed here:  https://community.skuid.com/t/calling-apex-function


Hi Rob, It is my Visualforce page Code, Sorry i’m not mention this line in previous post. Here my question is How we can achieve this type of mailing functionality ? We are developing Skuid page to replace Visualforce page, we are struck at this functionality Actual functionality of VF Page was “when the user click SAVE button, 1. Records creation/updation in Standard/custom object and 2. Sending an Email with template” We don’t know how to achieve the second point by using snippet???. Please help me out Thank you Shaik.

I’d keep this funtion in your VF page, and then include the Skuid page in your vf page using the skuid:page method. That method is detailed in Zach’s post that I linked to above. It is option #4 in his write up.

Hi Rob,

Thanks for your replay, We did sending mail  functionality :), With option#1 from Zach’s post.

Thank you


Shaik.