You need to sign in to do that
Don't have an account?

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 (http://wiki.developerforce.com/index.php/Visualforce_EmailQuote2PDF) 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,
VK
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:form>
<apex:outputPanel rendered="false">{!Quote__c.Contact__c}</apex:outputPanel>
</apex:page>
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 = t.id;
m.targetObjectId = q.contact__c;
m.whatId = q.id;
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()));
}
}
}
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.