global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
Lead ld = new Lead();
ld.Company ='bbc';
//ld.LastName='Abhi Sinha';
// system.Debug('Replacevalue ' + email.plainTextBody.replace('\n',''));
String[] bodySplitted = email.PlainTextBody.split('\r\n');
System.debug(bodySplitted +'bodySplitted');
String firstName = bodySplitted[0].substringAfter(': ');
System.debug(firstName +'firstName ');
ld.LastName= bodySplitted[1].substringAfter(': ');
// System.debug(email.plainTextBody +'TextBody');
//c.First Name= email.plainTextBody;
insert ld;
result.success = true;
return result;
}
Unable to get the field.array out of bound exception
Email body is like this
Firstname: starone1256 Lastname : startwo876

bodySplittedin your debug? – Mr.Frodo Jun 09 '18 at 09:01