You need to sign in to do that
Don't have an account?
HOW TO CALL EMAIL SERVICE (EMAIL TO LEAD) CLASS IN ANONYMOUS WINDOW
global class CreateLeadExample implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
String myPlainText= '';
myPlainText = email.plainTextBody;
Lead[] leads = [SELECT Id, Name, Email FROM Lead WHERE Email = :email.fromAddress];
if (leads.size() == 0) {
Lead newLead = new Lead(Email = email.fromAddress, LastName = 'From Email', Company = 'From Email');
insert newLead;
System.debug('New Lead record: ' + newLead ); }
else {
System.debug('Incoming email duplicates existing Lead record(s): ' + leads ); }
result.success = true;
return result;
}
}
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
String myPlainText= '';
myPlainText = email.plainTextBody;
Lead[] leads = [SELECT Id, Name, Email FROM Lead WHERE Email = :email.fromAddress];
if (leads.size() == 0) {
Lead newLead = new Lead(Email = email.fromAddress, LastName = 'From Email', Company = 'From Email');
insert newLead;
System.debug('New Lead record: ' + newLead ); }
else {
System.debug('Incoming email duplicates existing Lead record(s): ' + leads ); }
result.success = true;
return result;
}
}
You can call this class from anonomous window as below.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,