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

How to send a visual force page as email after clicking the cutom button on detail page



        I have two custom objects one is package and second is transaction. Transaction is the child of package. I made a visual force page which including the details of transaction. I am taken two custom detail buttons in the package object. one button is for generating the pdf with transction details and another button is for mailing the pdf to corresponding mail id of package.  Actually i generate pdf with transaction details. 


Any one help me out, how to email this pdf to corresponding mail id of package.





in the button click u can write  a method to grab the page data like pagereference pf = page.yourvfpagename;


by using this pf u can get the the page data as blob and add this blob as the body to the messaging.single email object's body.



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


mail.setHtmlBody = your blob value;

and use


Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); --> to send the email.. here you have to specify the toaddress....

Abhishek RayAbhishek Ray

Hi guys, I was looking for similar code. Will you please help? Here is the requirement

I want to create a send email button which capture the a page from an object - "click 10 point". When a opportuntiy is created, in the opportunity page there is a option for 10 point and when the user clicks it takes some of the field from opportunity into this click 10 point and a different page is diaplayed with some new fields. Now, I want to capture and send an email for this page using on send button. How to do create that send button?
If possible can you send the code where I can look for reference as I am new to visualforce page and how I can achieve it?




we also want a solution for the same issue.....

i am displaying the meeting details in the visual force page inside an html table. I want the same to be displayed as the body of the mail. i dont want it to be in the attachments of the mail

can u provide a sample code to display a vf page content as an email body

Jonathan Alush-AbenJonathan Alush-Aben
Did you end up finding a solution? Could you share it with me?