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
SFDCDoctorStrangeSFDCDoctorStrange 

Urgent! Want to Create Apex class for receiving mail and import its attached csv file

hey All,

i have a requriement for make apex class for getting attached excel from mail and import that file in Salesforce object

here is what i found till now

Apex class
global class ExcelInvoiceUpload implements Messaging.InboundEmailHandler
{
    
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope envelope)
    {
        
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        
        Messaging.InboundEmail.TextAttachment[] tAttachments = email.textAttachments;
        
        Messaging.InboundEmail.BinaryAttachment[] bAttachments = email.BinaryAttachments;
        
        String csvbody='';
        
        
        
        if(bAttachments !=null)
        {
            for(Messaging.InboundEmail.BinaryAttachment btt : bAttachments)
            {
                System.debug('this looks like a binary attachment'); 
                if(btt.filename.endsWith('.csv'))
                {
                    csvbody = btt.body.toString();
                    
                }
                
            }
            
        }
        
        else
            if(tAttachments !=null)
        {
            
            for(Messaging.InboundEmail.TextAttachment ttt : tAttachments)
            {
                System.debug('this looks like a text attachment');
                
                if(ttt.filename.endsWith('.csv'))
                { 
                    csvbody = ttt.body;                              
                }
                
            }
            
        }
        return result;
    }
}
for getting inbound  mail

apex class for break csv to into parts

apex class
global with sharing class CSVIterator implements Iterator<String>, Iterable<String>
{
   private String m_CSVData;
   private String m_introValue;
   public CSVIterator(String fileData, String introValue)
   {
      m_CSVData = fileData;
      m_introValue = introValue; 
   }
   global Boolean hasNext()
   {
      return m_CSVData.length() > 1 ? true : false;
   }
   global String next()
   {
      String row = m_CSVData.subString(0, m_CSVData.indexOf(m_introValue));
      m_CSVData = m_CSVData.subString(m_CSVData.indexOf(m_introValue) + m_introValue.length(),m_CSVData.length());
      return row;
   }
   global Iterator<String> Iterator()
   {
      return this;   
   }
}

batch apex class
global with sharing class ReadAndPopulateBatch implements Database.batchable<String>, Database.Stateful
{
   private String m_csvFile;
   private Integer m_startRow;
   private CSVParser m_parser; 
   private static final Integer SCOPE_SIZE = 100;
   public ReadAndPopulateBatch()
   {
     
   }
   public static ID run()
   {
              
   }
   global Iterable<String> start(Database.batchableContext batchableContext)
   { 
       return new CSVIterator(m_csvFile, m_parser.crlf);
   }
   global void execute(Database.BatchableContext batchableContext, List<String> scope)  
   {
       //TODO: Create a map with the column name and the position.
       String csvFile = '';
       for(String row : scope)
       {
          csvFile += row + m_parser.crlf;
       }                   
       List<List<String>> csvLines = CSVReader.readCSVFile(csvFile,m_parser);
       //TODO: csvLines contains a List with the values of the CSV file.
       //These information will be used to create a custom object to
       //process it.
   }
   global void finish(Database.BatchableContext batchableContext)
   {
       
   }
}

im getting error in this line
private CSVParser m_parser; 
invalid type : CSVParser

please explain help me create this 

Thanks & regards
Himanshu