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
suji srinivasansuji srinivasan 

How to attach vf page as pdf attachment in email ?

Can anyone guide me  how to use this in vf components  or can i attach this directly in email template?

vf page
<apex:page standardController="Salary_Detail__c" extensions="salarydetails" renderAs="pdf" >

<table>
         <apex:repeat value="{!Salary_Detail__c}" var="a" >
            <tr>
                 
                       <td  >Emp Code</td>
                       
                        <td >{!Salary_Detail__c.Employee_ID__c}
                      
                         </td>                     
              </apex:repeat >
</table> </apex:page>


-------------------
vf page apex class

public class salarydetails {

public Salary_Detail__c SalaryDetail{get;set;}
        private ApexPages.StandardController controller;
        public SalaryDetails(ApexPages.StandardController controller){
                //this.SalaryDetail = (Salary_Detail__c)StandardController.getRecord();
        }

        Public PageReference saveRecord() {
                insert SalaryDetail;
                PageReference pr = new PageReference('/'+SalaryDetail.id);
                pr.setRedirect(true);
            return pr;}}

Thanks in advance
Best Answer chosen by suji srinivasan
mukesh guptamukesh gupta
Hi Suji,

Please follow below url, that's will help for your solution

https://salesforcescool.blogspot.com/2019/01/send-pdf-as-attachment-in-visualforce.html

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

All Answers

PriyaPriya (Salesforce Developers) 

Hi Suji,
Please refer the below links for reference :-

https://developer.salesforce.com/forums/?id=906F0000000MGuwIAG

https://success.salesforce.com/answers?id=90630000000gtkuAAA

https://salesforce.stackexchange.com/questions/330888/how-can-a-vf-page-be-attached-to-an-email-as-a-pdf-attachment-in-landscape-forma

hope it will be helpful.

Please mark it as best answer if the information is informative.

Thanks & Regards,

Priya Ranjan

mukesh guptamukesh gupta
Hi Suji,

Please follow below url, that's will help for your solution

https://salesforcescool.blogspot.com/2019/01/send-pdf-as-attachment-in-visualforce.html

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
This was selected as the best answer