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
Ramya BalakrishnanRamya Balakrishnan 

sendemail exception Storage limit exceeded

Hi all

I have this following method which is sending email.It was working fine till yesterday. I just changed the message in email template today .when i try to test it showing STORAGE_LIMIT_EXCEEDED exception. I tried with different emails also. It is not working. Can anybody give solution to this.

private void sendEmail(){
        String EmailBody,Subject;
        Contact prjLead;
        String prjLeadEmail;
        List<EmailTemplate> emailTemplateIds = new List<EmailTemplate>();
      
         //Fetch Email Template Id to be send to Candidate and Project Lead 
         
         If(removeProjInterest = True) 
             emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Request_To_Leave_Project' LIMIT 1] ;
                                                
                                                 
         else                                                   
              emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Project_Join_Request' LIMIT 1];                                     
        
        //Fetch the Project Lead Details
        If(selPrjLeadId != null){
             prjLead = [SELECT Id,FirstName,Name,Email 
                                         FROM Contact 
                                         WHERE id=:selPrjLeadId 
                                         LIMIT 1];
             projectLead = prjLead.Name; // Value referred in VF Page
             prjLeadEmail = prjLead.Email;
             prjLeadOrManager = 'project lead';  //Value referred in VF Page
        } else{
            //If Project Lead not defined, Email fetched from Custom Metadata settings
            MR_Project_List_Setting__mdt PrjListMetaData = [SELECT PMO_Email__c,PMO_Name__c 
                                                                  FROM MR_Project_List_Setting__mdt
                                                                  WHERE DeveloperName  ='PMO_Details' LIMIT 1];
            projectLead = PrjListMetaData.PMO_Name__c;
            prjLeadEmail = PrjListMetaData.PMO_Email__c;
            prjLeadOrManager = 'project manager';      //Value referred in VF Page
        }
        
        //New instance of a single email message sent to candidate
       Messaging.SingleEmailMessage emailCand = new Messaging.SingleEmailMessage();
       List<String> canEmailList = new List<String>();
       List<String> prjLeadEmailList = new List<String>();
        
        //Fetch the Candidate details
       If(contactId != null){
             
              EmailBody = emailTemplateIds.get(0).Body;
           If(EmailBody !=null){
               EmailBody = EmailBody.replace('Candidate',candFirstName);
               EmailBody = EmailBody.replace('project', selPrjName);                        
               EmailBody = EmailBody.replace('lead',projectLead);
               EmailBody = EmailBody.replace('plOrpm', prjLeadOrManager); 
               EmailBody = EmailBody.replace('LeadEmail',prjLeadEmail);  
               if(removeProjInterest = True) 
               {
               EmailBody = EmailBody.replace('CandEmail',candEmail);
               }
            
           }
              canEmailList.add(candEmail);
              emailCand.toaddresses =canEmailList;
              prjLeadEmailList.add(prjLeadEmail);
              emailCand.ccaddresses = prjLeadEmailList;
              emailCand.setTargetObjectId(contactId);
               Subject = emailTemplateIds[0].Subject;
               emailCand.setSubject(Subject); 
                emailCand.setPlainTextBody(EmailBody);
              try{            
                  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailCand });
                  system.debug('Candidate & Project Lead Email Sent Successfully');
              }  catch(exception e){
                      system.debug('Error email');
                      apexpages.addmessage(new apexpages.message(apexpages.severity.error,e.getMessage()));
                      system.debug('Error Sending Candidate and Project Lead email '+e.getMessage());
               }
        
        }
            
 }
    

15:48:46.0 (588298556)|EXCEPTION_THROWN|[338]|System.EmailException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (588751848)|HEAP_ALLOCATE|[338]|Bytes:111 15:48:46.0 (588837018)|VARIABLE_SCOPE_BEGIN|[340]|e|Exception|true|false 15:48:46.0 (588947495)|VARIABLE_ASSIGNMENT|[340]|e|"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"|0xf2b3972 15:48:46.0 (588958756)|STATEMENT_EXECUTE|[340] 15:48:46.0 (588961850)|STATEMENT_EXECUTE|[341] 15:48:46.0 (588991982)|HEAP_ALLOCATE|[341]|Bytes:11 15:48:46.0 (589045155)|USER_DEBUG|[341]|DEBUG|Error email 15:48:46.0 (589057755)|STATEMENT_EXECUTE|[342] 15:48:46.0 (589254533)|HEAP_ALLOCATE|[342]|Bytes:107 15:48:46.0 (589428174)|VF_PAGE_MESSAGE|SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589439526)|STATEMENT_EXECUTE|[343] 15:48:46.0 (589451863)|HEAP_ALLOCATE|[343]|Bytes:47 15:48:46.0 (589472850)|HEAP_ALLOCATE|[343]|Bytes:107 15:48:46.0 (589489892)|HEAP_ALLOCATE|[343]|Bytes:154 15:48:46.0 (589502124)|USER_DEBUG|[343]|DEBUG|Error Sending Candidate and Project Lead email SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589525677)|METHOD_EXIT|[694]|01p3u00000ILbF5|ProjectsList.sendEmail()
VinayVinay (Salesforce Developers) 
Hi Ramya,

To fix STORAGE_LIMIT_EXCEEDED issue you can do below.

> Increase your data storage by contacting Salesforce Support Team
> Delete unneeded data/files.

Check below references.
https://help.salesforce.com/s/articleView?id=000349542&type=1
https://www.infallibletechie.com/2014/11/storagelimitexceeded-issue-in-salesforce.html

Please mark as Best Answer if above information was helpful.

Thanks,
mukesh guptamukesh gupta
Hi Ramrya,

Solution to fix the STORAGE_LIMIT_EXCEEDED issue in Salesforce: please naviage the below steps:
Go to Setup –> Administer –> Data Management –> Storage Use and remove the unwanted data or files using dataloader or scripts.

User-added image

To fix STORAGE_LIMIT_EXCEEDED issue you can do one of the following:-Increase your data storage by contacting Salesforce Support Team
Delete unneeded data/files.

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
Ramya BalakrishnanRamya Balakrishnan
Thank you Mukesh.