function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Quote2pdf help!

Hello All,


Happy New Year!


Please help me with this issue which I am trying to solve since many days.

I am using the Quote2PDF ( This package is awesome.


All I want is to add a custom button "Email Quote" which sends email automatically(with attached PDF quote) to the contact associated.


Sorry, if this question is already posted. I am unable to find a solution to this.

Any help or pointers how to implement this will be much appreciated.


Thanks a lot,



I should probably add this to the package but I'll just post it here now for your benefit.  This page sends the email when you click the send button:


The Visualforce page:


<apex:page standardController="Quote__c" extensions="QuoteEmailPdfExt">
<apex:form >
<apex:pageMessages />
<apex:commandButton value="Send" action="{!sendQuotePdf}"/>
<apex:outputPanel rendered="false">{!Quote__c.Contact__c}</apex:outputPanel>


The Apex class:


public class QuoteEmailPdfExt {

public Quote__c q { get; set; }

public QuoteEmailPdfExt(ApexPages.StandardController controller) {
q = (Quote__c) controller.getRecord();

public void sendQuotePdf() {

EmailTemplate t = [select id from EmailTemplate where DeveloperName = 'Quote'];

Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();

m.templateId =;
m.targetObjectId = q.contact__c;
m.whatId =;

Messaging.SendEmailResult result = Messaging.sendEmail(new Messaging.Email[]{m}).get(0);
if(result.isSuccess()) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Email sent :)'));
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Whoops: ' + result.getErrors()));




If you want to put a button on the quote page that does this automatically then update the page above to bind the page's action attribute directly to the sendQuotePdf() method and then create a custom button on Quote that uses this page. 


You'll also want to modify the page to remove the button, obviously, but don't remove the pageMessages component as it conveys the success/error messages as appropriate.

Message Edited by mtbclimber on 02-11-2010 11:05 PM