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
Akshay Alandkar 8Akshay Alandkar 8 

created visualforce page but unable to send attachment

i have created visualforce page and its class 

<apex:page showHeader="false" standardStylesheets="false" sidebar="false" controller="Feedbackpagehandler"> 
    <style>
        .field {
            box-sizing: border-box;
        }
        .field > div {
            box-sizing: border-box;
            display: inline-block;
            padding-top: 5px;
            padding-bottom: 5px;
        }
        .field > div:first-child {
            width: 20%;
            float: left;
            padding-right: 10px;
            vertical-align: top;
            text-align: right;
        }
        .field > div:first-child + div {
            width: 50%;
        }
        .required {
            color: red;
        }
    </style>
    <GNT:ExternalLibrary />   
    <apex:composition template="GNT__ModalTemplate">
        <apex:define name="ModalContent"> 
        
            <apex:form > 
                <GNT:PageMessages id="editPageErrors"/>
        <!--        <apex:actionFunction name="submitCase" action="{!submitCase}" status="requestIcon">
                    <apex:param name="requestString" value="" assignTo="{!requestString}"/>
                </apex:actionFunction>
           -->     
                    <apex:define name="Header">
                        <h2>Create Feedback</h2>
                    </apex:define>
                    <apex:define name="Inputs">
                   
            <!--            <input value="Submit" type="button" class="customBtn" id="submitcase"/>   -->
                     <button style="float:Right;" type="cancel" class="customBtn" onclick="javascript:window.location='https://lsc-grantease--qa--c.sandbox.vf.force.com/apex/PhaseView?t=GrantorHome';">Cancel</button>  
                     <apex:commandbutton action="{!SaveMethod}" style="float:Right;" value="Submit"   onclick="javascript:window.location='https://lsc-grantease--qa--c.sandbox.vf.force.com/apex/PhaseView?t=GrantorHome';"/>  
                    
                   
                    </apex:define>
                    <apex:define name="Body">
                        
                        <div id="issueType" class="field">
                            <div>
                                <strong>Issue Type<span class="required">*</span> </strong>
                            </div>
                            <div>
                                <apex:inputField value="{!LSCFeedback.Type__c}" required="true"/>
                            </div>
                        </div>
                        <div id="subject" class="field">
                            <div>
                                <strong>Subject<span class="required">*</span> </strong>
                            </div>
                            <div>
                                <apex:inputText value="{!LSCFeedback.Subject__c}" size="80" required="true"/>
                            </div>
                        </div>
                        <div id="issueDescription" class="field">
                            <div>
                                <strong>Description<span class="required">*</span> </strong>
                            </div>
                            <div>
                                <apex:inputTextarea value="{!LSCFeedback.Description__c}" richText="true" required="true"/>
                            </div>
                        </div>
                        <div id="issueLocation" class="field">
                            <div>
                                <strong>URL </strong>
                            </div>
                            <div>
                                <apex:inputText value="{!LSCFeedback.URL__c}" size="80" required="false"/>
                            </div>
                        </div>
                        <div id="attachments" class="field">
                            <div>
                                <strong>Add Attachment </strong>
                            </div>
                            <div>
                                <apex:inputFile id="Attachment" filename="{!attachmentName}" value="{!attachment}" accept="image/*"/>
                            </div>
                        </div>
                        
                       

   </apex:define>
   </apex:form>
   </apex:define>
   
   </apex:composition>
</apex:page>



and its class 

 

public without sharing class Feedbackpagehandler{

public PageReference cancel() {
return null;
}

public LSCFeedback__c LSCFeedback{get;set;}
public Boolean isInternal {get;set;}
public Blob attachment {get;set;}
public String attachmentName {get;set;}
public String returnURL {get;set;}
private User user;

public Feedbackpagehandler() {
LSCFeedback = new LSCFeedback__c();
user = [SELECT id, Email, ProfileId, UserType FROM User WHERE id =: UserInfo.getUserId()];

isInternal = isInternalUser();
returnURL = setReturnURL();

}



//Save Method
public PageReference SaveMethod(){
Insert LSCFeedback;


Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

String[] toAddresses = new String[] { 'abcd@yopmail.com' };




mail.setToAddresses(toAddresses);
mail.setSubject('New Feedback Form created');
mail.setBccSender(false);
mail.sethtmlBody('Issue Type: ' + LSCFeedback.Type__c +
'<br/><br/> Subject: '+LSCFeedback.Subject__C +
'<br/><br/> Description: '+LSCFeedback.Description__c +
'<br/><br/> URL: '+LSCFeedback.URL__c
);


// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });




PageReference pageRef = new PageReference('/apex/PhaseView?t=GrantorHome');
pageRef.setRedirect(true);
return pageRef;



}






private Boolean isInternalUser() {
Boolean isInternal = false;
if(user.UserType.contains('Standard')) {
isInternal = true;
}
return isInternal;
}

private String setReturnURL() {
String returnURL = '/apex/PhaseView?t=GrantorHome';
/* if(isInternal) {
returnURL += 'GrantorHome';
} else {
returnURL += 'RecipientHome';
}
*/
return returnURL;
}
}


But when i submit this form and open email 
User-added imagedidnt get attachment ,can you please tell me how to get attachment to mail