+ Start a Discussion
shashikant pandeyshashikant pandey 

Getting {faultcode:'soapenv:Client; faultstring:'No operation available for request{http://soap.sforce.com/schemas/package/sendEmailAttachmentPR}sendEmailAttachment, please check the WSDL for the service.'}

Below are the my code:
Apex class:
public class sendEmailAttachmentPR {
    public Pricing_Reconfirmation__c prId{get;set;}
    public String primaryContactId {get;set;}
    public String AccountId{get;set;}
    public String email{get;set;}
    
    public pagereference sendEmailAttchament(){
        
        prId = [Select Id,Name,Account__r.Id,Primary_Contact__r.id from Pricing_Reconfirmation__c where id =: ApexPages.currentPage().getParameters().get('id')];
        primaryContactId = prId.Primary_Contact__r.id;
        AccountId = prId.Account__r.Id;
        system.debug('Primary Contact Id ====>'+primaryContactId);
        system.debug('Account Id ===> '+AccountId);
        
        Contact con = [SELECT ID,Name,Email,Phone from Contact where Id =:primaryContactId];
        email = con.email;
        system.debug('Email Id  =======>'+email);
        User currentUser = [SELECT Id FROM User Where Id = :UserInfo.getUserId()];
        
        Attachment attachFile = [SELECT Id,Name,parentId,LastmodifiedDate,ContentType,body FROM Attachment where parentId=:prId.Id ORDER BY LastmodifiedDate Desc LIMIT 1];
        system.debug('Attachment File Id '+attachFile.id);
      
            Messaging.EmailFileAttachment emailAttach = new Messaging.EmailFileAttachment();
            emailAttach.setContentType(attachFile.ContentType);
            system.debug('ContentType ====> '+attachFile.ContentType);
            emailAttach.setFileName(attachFile.Name);
            system.debug('FIle Name ===>'+attachFile.Name);
            emailAttach.setInline(false);
            emailAttach.Body = attachFile.Body;
            system.debug('Body ====> '+emailAttach.Body);
            
            
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            semail.setEntityAttachments(new Id[]{attachFile.Id});
            semail.setSubject('Sending Document as attachemnt');
            String[] sendTo = new String[]{'shashikant.pandey2@wipro.com'};
                semail.setToAddresses(sendTo);
            semail.setPlainTextBody('Please find the attached document details');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            
            system.debug('Email Sent Successfully');
        
            //system.debug('Email Id available for Contact');
     
        return null;
    }

}

Button OnClick JavaScript 

{!REQUIRESCRIPT("/soap/ajax/49.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/49.0/apex.js")}
var prId = "{!Pricing_Reconfirmation__c.Id}";
sforce.apex.execute("sendEmailAttachmentPR","sendEmailAttchament",{});
sforce.debug.trace=true;
window.location.reload();
alert("Email Sent Successfully");

Even I am tryning through command button as well but email not getting sent.
VF page:
<apex:page controller="sendEmailAttachmentPR">
    
    <apex:form >
        <apex:pageMessages />
        <apex:commandButton value="Send Email" action="{!sendEmailAttchament}"/>
    </apex:form>  
</apex:page>

Email is not getting send. could anyone help me here?