+ Start a Discussion
Ram ParitalaRam Paritala 

i want to send an email by clicking "sendemail" button in a standard page. how can i acheive this ??

NagendraNagendra (Salesforce Developers) 
Hi Ram,

May I request you please elaborate your requirement so that we can understand better and can help you accordingly.


For example, we are working on a standard lead object and you want to open a specific e-mail template pre-filled with the Lead's name and e-mail address so that you can then send the e-mail to the Lead's e-mail. 

If your requirement is something similar to the above then the below code should do the trick.


Create an Apex Class with the following code.
public class testemail
private final Contact con;
public testemail(ApexPages.StandardController controller)

public void SendEmail()
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Mention a valid Email Template ID in the colored part...

Step 2:

Create a VF page named as "testemail" or anything as your wish, and paste the code below.
<apex:page standardcontroller="Contact" extensions="testemail">
<apex:commandButton value="Send Email!" action="{!SendEmail}"/>

Step 3:
Go to the URL bar and type
Note that make sure you mention a valid contact ID of your SF instance.

Please let us know if you are looking anything else other than this.

Happy to help further.

Kindly mark this as solved if the reply was helpful.