Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithmancuso/9539cafab1bb3ea45dada8546f31c9c5 to your computer and use it in GitHub Desktop.
Save keithmancuso/9539cafab1bb3ea45dada8546f31c9c5 to your computer and use it in GitHub Desktop.
Attach PDF
PageReference pdf = Page.PrintSet;
pdf.getParameters().put('id',customerId);
pdf.setRedirect(true);
// Take the PDF contents
Blob b = pdf.getContent();
// Create the email attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('actionPlan.pdf');
efa.setBody(b);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment