You need to sign in to do that
Don't have an account?
Ghanesan
Create a Pdf from HTML Email Template
Hi,
I am trying to create PDF from a HTML Email Template. i have a requirement to create a offer letter as a pdf and send email with pdf attachment to the selected candidate.
My idea on this requirement is, first create a pdf from HTML Email Template (with all merge fields) and Create custom button on the UI page for sending email.
I am trying to create PDF from a HTML Email Template. i have a requirement to create a offer letter as a pdf and send email with pdf attachment to the selected candidate.
My idea on this requirement is, first create a pdf from HTML Email Template (with all merge fields) and Create custom button on the UI page for sending email.
Check below example for Creating a Pdf from HTML Email Template
https://salesforcecodex.com/salesforce/send-email-template-as-pdf-attachment-using-salesforce-apex/
https://pdf.co/convert-html-to-pdf-in-salesforce-apex-using-pdfco
Please mark as Best Answer if above information was helpful.
Thanks,
I have tried the above link already, when i debug the error is popups.
Line : 5, Column: 1
System.QueryException: List has no rows for assignment to SObject
Code:
public class PDFGenerationService {
public static void generatePDF()
{
EmailTemplate coverTemplate = EmailTemplateSelector.getEmailTemplate('Venolin Offer Letter');
EmailTemplate attachTemplate = EmailTemplateSelector.getEmailTemplate('Offer');
if(attachTemplate!=null && coverTemplate!=null)
{
Map<String, String> ncParams=new Map<String, String> {'{name}' => 'T'};
Messaging.EmailFileAttachment attach = EmailHelper.attachementBuilder('OfferLetter.pdf',attachTemplate.HtmlValue,null);
Messaging.SingleEmailMessage mail=EmailHelper.emailBuilder('T@gmail.com',coverTemplate.Subject,coverTemplate.HtmlValue,ncParams);
// Send the email
//
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}