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
Intigration vIntigration v 

Example code to send selected Files through Email on Visualforce page

I have a requirement to display the files attached to work order object on vfpage and what ever the files that are selected by the user need to be send through mail.
Need to display button on workorder and when he clicks that button list of files need to be diaplayed on page .After selecting the files it should send to user by Email.
Please share the example code to achieve this requirement.

Thank you!
PriyaPriya (Salesforce Developers) 


Kindly refer this link example that matches your requirement:-

Kindly mark it as the best answer if it helps.

Priya Ranjan

Siva Krishna KondapalliSiva Krishna Kondapalli
<apex:component access="global"> <h1>Account Details</h1> <apex:panelGrid columns="2"> <apex:outputLabel for="Name" value="Name"/> <apex:outputText id="Name" value="{!account.Name}"/> <apex:outputLabel for="Owner" value="Account Owner"/> <apex:outputText id="Owner" value="{!account.Owner.Name}"/> <apex:outputLabel for="AnnualRevenue" value="Annual Revenue"/> <apex:outputText id="AnnualRevenue" value="{0,number,currency}"> <apex:param value="{!account.AnnualRevenue}"/> </apex:outputText> <apex:outputLabel for="NumberOfEmployees" value="Employees"/> <apex:outputText id="NumberOfEmployees" value="{!account.NumberOfEmployees}"/> </apex:panelGrid> </apex:component>

<apex:page standardController="account" renderAs="PDF"> <c:attachment/> </apex:page>

Then add the custom component to render at the bottom of your previous sendEmailPage:

<apex:pageBlock title="Preview the Attachment for {!}"> <c:attachment/> </apex:pageBlock>

Sending an Email with an Attachment

<apex:page controller="sendEmail"> <apex:messages/> <apex:pageBlock title="Send an Email to Your {!} Representatives"> <p>Fill out the fields below to test how you might send an email to a user.</p> <apex:dataTable value="{!account.Contacts}" var="contact" border="1"> <apex:column> <apex:facet name="header">Name</apex:facet> {!contact.Name} </apex:column> <apex:column> <apex:facet name="header">Email</apex:facet> {!contact.Email} </apex:column> </apex:dataTable> <apex:form><br/><br/> <apex:outputLabel value="Subject" for="Subject"/>: <br/> <apex:inputText value="{!subject}" id="Subject" maxlength="80"/> <br/><br/> <apex:outputLabel value="Body" for="Body"/>: <br/> <apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/> <br/><br/> <apex:commandButton value="Send Email" action="{!send}"/> </apex:form> </apex:pageBlock> <apex:pageBlock title="Preview the Attachment for {!}"> <c:attachment/> </apex:pageBlock> </apex:page>

If this helps please mark my answer as best.