How to send email from Snippet ?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
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.
Photo of Shaik

Shaik

  • 370 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
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.skuidify.com/skuid/topics/calling_apex_function
Photo of Shaik

Shaik

  • 370 Points 250 badge 2x thumb
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.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
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. 
Photo of Shaik

Shaik

  • 370 Points 250 badge 2x thumb
Hi Rob,

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

Thank you


Shaik.
(Edited)