+ Start a Discussion
PuranKishorePuranKishore 

I am trying to create 50000 records using batch apex using email service

 method i had created an object of email service


global class CaptureEmail implements Messaging.InboundEmailHandler
{
 
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope env)
    {
 
    Messaging.InboundEmailResult res = new Messaging.InboundEmailresult();
   
    Email_Object_Simple__c ema = new Email_Object_Simple__c();
    
    for(integer i=1;i<=50001;i++)
    {
    ema.Name__c= email.fromname;
    //ema.LastName = email.fromname;
    ema.Email__c = env.fromAddress;
    ema.Description__c=email.subject;
   
    String [] emailBody = email.plainTextBody.split('\n', 0);
   
    ema.PhoneNumber__c = emailBody[0].substring(12);
    ema.Qualification__c = emailBody[1].substring(14);
    ema.Technology__c = emailBody[2].substring(11);
    ema.City__c = emailBody[3].substring(5);
    ema.State__c = emailBody[4].substring(6);
    ema.Country__c = emailBody[5].substring(8);
    }
    insert ema;
       Messaging.SingleEmailMessage emailsend = new Messaging.SingleEmailMessage();
        string [] toaddress= New string[]{env.fromAddress};
        emailsend .setSubject('Congragulation...!');
        emailsend .setPlainTextBody('Thanks For Sending your Information');
        emailsend .setToAddresses(toaddress);
        Messaging.sendEmail(New Messaging.SingleEmailMessage[]{emailsend });
    return res;
   
   
    }
   
        
}
sandeep@Salesforcesandeep@Salesforce

Please share issue you were facing here.

Bhawani SharmaBhawani Sharma
What issue you are facing?
ForcepowerForcepower

That looks like the regular inbound email handler service that is receiving one email and sending an auto response to it. Are you trying to convert this into batch? That won't help with the limit that Salesforce has, of 1000 external emails per day. Each auto response you're sending would count against the limit. I think you'll need a third party email solution from AppExchange to help you out.

Ram