+ Start a Discussion

Send mass email with attachment (attachment need to select from vf page) with template

I have a vf page with email template pick list user able to select email template name
Choose file : user able to upload a file attachment from his computer.
there is a command button send email . once clicking on send email need to send email with selected template with email attachment . please help me on this.. sample code :
<apex:page standardController="Contact" extensions="WrapperClsOnContactMass">
    <apex:form >
    <apex:pageMessages >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!wrapperObj}" var="x">
                <apex:column value="{!x.conobj.name}"/>
                <apex:column value="{!x.conobj.email}"/>
                <apex:column >
                  <apex:inputcheckbox value="{!x.checkBox }"/>
            <apex:pageBlockSection >
            <apex:commandButton value="SendEmail" action="{!sendEmail}"/>
public with sharing class WrapperClsOnContactMass {

    public List<WrapperClassEx> WrapperList{get;set;}
    public WrapperClsOnContactMass(ApexPages.StandardController controller) {
    public List<WrapperClassEx> getwrapperObj(){
        List<Contact> conList =[select id, name, email from contact limit 5];   
        WrapperList = new List<WrapperClassEx>();
        for(Contact con: conList){
            WrapperList.add(New WrapperClassEx(con,false));  
        return WrapperList;  
    public class WrapperClassEx{
       public WrapperClassEx(){
       public Contact conObj{get;set;}
       public Boolean checkBox{get;set;}
       public WrapperClassEx(Contact conRec, boolean SelectedBox){               
          conObj= conRec;
          checkBox = SelectedBox;
       public void sendEmail(){
         List<Messaging.SingleEmailMessage> lstEmailId=new List<Messaging.SingleEmailMessage>();
         for(WrapperClassEx w: WrapperList){
            if(w.checkBox == true){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[] {w.conObj.Email});
                mail.setSenderDisplayName('Your Company Name');
                mail.setSubject('Test Email From Force.com Sites');
                    ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'Sent!'));
                }Catch(Exception ee){
                    ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Error,ee.getMessage()));