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

Example code to send selected Files through Email on Visualforce page
Hi,
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!
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!
Hey
Kindly refer this link example that matches your requirement:-
https://salesforce.stackexchange.com/questions/178765/upload-attachments-and-send-with-email
Kindly mark it as the best answer if it helps.
Thanks!
Priya Ranjan
<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 {!account.name}"> <c:attachment/> </apex:pageBlock>
Sending an Email with an Attachment
<apex:page controller="sendEmail"> <apex:messages/> <apex:pageBlock title="Send an Email to Your {!account.name} 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 {!account.name}"> <c:attachment/> </apex:pageBlock> </apex:page>
If this helps please mark my answer as best.