Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<apex:form id="emailForm"> <a href="#" id="emailUs">Email Us</a> <apex:outputLink value="/apex/trialAndError?id=0019000000wE7hz"> trialAndError</apex:outputLink> <div id="overlay" class="web_dialog_overlay"></div> <div id="dialog" class="web_dialog"> <table style="width: 100%; border: 0px;" cellpadding="3" cellspacing="0"> <tr> <td class="web_dialog_title">Email</td> <td class="web_dialog_title align_right"> <button class="close-icon" id="btnClose"></button> </td> </tr> <tr><td> </td> <td> </td> </tr> <!-- for blank space --> <tr> <td class="emailLabel"><apex:outputLabel value="First Name"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!cust_fname}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Last Name"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!cust_Lname}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Company"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!cust_company}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Phone Number"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!cust_Phone}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Email"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!cust_Email}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Subject"></apex:outputLabel> </td> <td class="emailText"><apex:inputText value="{!Email_subject}" size="24"/></td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Country"></apex:outputLabel> </td> <td class="emailText"> <apex:selectList value="{!countries}" size="1"> <apex:selectOptions value="{!items}"/> </apex:selectList> </td> </tr> <tr> <td class="emailLabel"><apex:outputLabel value="Question/Comments"></apex:outputLabel> </td> <td class="emailText"><apex:inputTextArea value="{!cust_Comments}"/></td> </tr> </table><br/> <apex:commandButton value="Send Mail" action="{!SendMail}" oncomplete="CloseAndRefresh();" style="margin-left:34%;padding:5px;margin-bottom:10px;"/> <apex:outputText value="{!cust_company}"></apex:outputText> </div> </apex:form> =============================== public class emailPopupSendMailTrial { public string cust_fname{get;set;} public string cust_lname{get;set;} public string cust_company{get;set;} public string cust_phone{get;set;} public string cust_email{get;set;} public string cust_comments{get;set;} public string country{get;set;} String[] countries = new String[]{}; public string Email_Subject{get;set;} // code section for displaying the list of countries public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); options.add(new SelectOption('US','US')); options.add(new SelectOption('CANADA','Canada')); options.add(new SelectOption('MEXICO','Mexico')); return options; } public String[] getCountries() { return countries; } public void setCountries(String[] countries) { this.countries = countries; } // end of the code section of list of countries // Code section for sending the mail after clicking on the send mail button public PageReference SendMail() { String[] recipients = new String[]{'dearrishav@gmail.com'}; Messaging.reserveSingleEmailCapacity(recipients.size()); Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage(); msg.setToAddresses(recipients); msg.setSubject('Test Email Subject'); msg.setHtmlBody('Test body including HTML markup'); msg.setPlainTextBody('Test body excluding HTML markup'); msg.setSaveAsActivity(false); msg.setUseSignature(false); Messaging.sendEmail(new Messaging.SingleEmailMessage[] {msg}, false); cust_company= 'yes this function is working'; return null; } }
Refer the below links.
https://www.salesforce.com/us/developer/docs/pages/Content/pages_email_custom_controller.htm
http://axoa-developer-edition.na10.force.com/SiteArticleDetailPage?id=a00A0000000yekiIAA
http://michaelwelburn.com/2013/03/18/sending-visualforce-pages-as-email-attachments-in-salesforce/
http://salesforceat360degrees.blogspot.in/2013/11/sending-email-with-attachment-using.html
i have made this program for practice purpose , you can customize it according to your need
Thanks
Rishav