You need to sign in to do that
Don't have an account?
Salvatore Gomez
Inbound Email Handler - convert Mailto link to plain text
The inbound email handler below works when the email address in the body is passed as plaintext. However, the email address in the body is usually in the format of an mailto link which prevents the submission of this lead. How can i convert the email address that is contained in the email body to plain text?
global class ProcessJobApplicantEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String RecordTypeId = '01280000000BWjJAAW';
String status = 'Open - New';
String LeadSource ='Referral';
String SecondLeadSource = 'Online Division';
String[] emailBody = email.plainTextBody.split('\n', 0);
String FirstName = emailBody[0].substring(11);
String LastName = emailBody[1].substring(10);
String EmailAddress = emailBody[2].substring(14);
String Phone = emailBody[3].substring(6);
Lead Lead = new Lead();
Lead.FirstName=FirstName;
Lead.LastName=LastName;
Lead.Phone= Phone;
Lead.Email=EmailAddress;
Lead.RecordTypeId= RecordTypeId;
Lead.status=status;
Lead.LeadSource=LeadSource;
Lead.Lead_Source_2__c=SecondLeadSource;
insert Lead;
System.debug('====> Created lead '+Lead.Id);
return result;
}
}
Thanks for your help
global class ProcessJobApplicantEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String RecordTypeId = '01280000000BWjJAAW';
String status = 'Open - New';
String LeadSource ='Referral';
String SecondLeadSource = 'Online Division';
String[] emailBody = email.plainTextBody.split('\n', 0);
String FirstName = emailBody[0].substring(11);
String LastName = emailBody[1].substring(10);
String EmailAddress = emailBody[2].substring(14);
String Phone = emailBody[3].substring(6);
Lead Lead = new Lead();
Lead.FirstName=FirstName;
Lead.LastName=LastName;
Lead.Phone= Phone;
Lead.Email=EmailAddress;
Lead.RecordTypeId= RecordTypeId;
Lead.status=status;
Lead.LeadSource=LeadSource;
Lead.Lead_Source_2__c=SecondLeadSource;
insert Lead;
System.debug('====> Created lead '+Lead.Id);
return result;
}
}
Thanks for your help
First Name: Test
Last Name: Test
Email Address: Test@test.com (mailto:Test@test.com)
Phone: 555-555-5555