May I request you please elaborate your requirement so that we can understand better and can help you accordingly.
Assuming,
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.
Step1:
Create an Apex Class with the following code.
public class testemail
{
private final Contact con;
public testemail(ApexPages.StandardController controller)
{
this.con=(Contact)controller.getRecord();
}
public void SendEmail()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(con.Id);
mail.setTemplateId('00X90000000QHUD');
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.
May I request you please elaborate your requirement so that we can understand better and can help you accordingly.
Assuming,
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.
Step1:
Create an Apex Class with the following code. 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.
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.
Thanks,
Nagendra