I have a custom object related to an Account and Contact which has a custom button which launches a VF PDF page showing some of the object's fields in a format more appropriate for customers to see. So far so good. The goal is to send this PDF as an attachment to a Contact. Easy enough:
public void emailPDF(Id id){
//the id parameter would be the object's id
PageReference pdf new PageReference('/apex/PDFReport');
pdf.getParameters().put('id',id);
pdf.setRedirect(true);
Blob blobOfPdf = pdf.getContent();
Messaging.EmailFileAttachment attch = new Messaging.EmailFileAttachment();
attch.setBody(blobOfPdf);
//set file name create email, set addresses set attachment etc.
}
Originally I was going to construct a button with a link to a VF page that has a text area to enter the body of the email or choose templates and then send the email and redirect to the custom objects page; however some of the sales reps would prefer to use Outlook to format the email and enter the body of the text etc.
I'm wondering if there is a way I can create the attachment, grab the applicable outgoing address, blind copy address to log the email in Activity, and any templates and then open this as a new email within Outlook for the reps to edit or add to before sending the email.