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
Eugene KorsunskyEugene Korsunsky 

Parsing emails to extrat data for new leads

I need to parse HTML emails from several sources to create new leads. I've created an Apex class where I can filter out new lead emails and separate email sources in order to apply related fixed formats. I still have problems wth extrracting the required data, such as first and last name, phone, email, and property address of interest. I have difficulty identifying correct line numbers in  String[] emailBody = email.plainTextBody.split('\n', 0);  and keep getting substring indexing errors. HTML and blank lines may be a problem. Can anybody help with the code? 
Thank you!

_______________________________

From Trulia 

Hi rentals@int ,
A new renter is interested in your listing at 4XX Norwood Cir. Check out the details below.
From: Anxxd xxxg
Email: anxxx@hotmail.com*
Phone: (408) 416-9XX9
Message: I am interested in this rental and would like to schedule a viewing. Please let me know when this would be possible.


From HOTPADS
 Mhlle contacted you about Delightful Cambrian 3 Bed 2 Bath Home.
 
From: Mhlle Kxx<mlsxxx88@gmail.com>
Phone: 40839824XX

I'm interested in XXX Frxxnela Drive, San Jose, CA 95124. Please contact me with more information!


 
 from Zillow


vxxx gyyy says:
" 27XX Massachusetts Ave, Redwood City, CA 94061 HI. we are moving from NY to Menlo Park in July. Is this place available to start from July - we are looking for a 1 yr lease. You can reach me at: (212) 5XX-0000 Contacted via Zillow.com"
Respond within 10 minutes for best results.
vaXXr@hotmail.com

212.52XX 0000

 this contact on Zillow.
CloudGoferCloudGofer
User-added image


If you are looking for advanced email to lead conversion app which does following

1. Configure data elements for parsing using simple configuration page (instead of coding)
2. Support multiple email templates/formats (includes html body format)
3. Set default values to lead fields (e.g. for record type, Lead source, Campaign)
4. Attach lead to a campaign
5. Process attachments
6. Simulate parsing of text to Lead (Built in simulator)
7. Extensive Error/Warning reporting

Then try Email2LeadPro AppExchange package: https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFoGaUAL

More details at: http://www.cloudgofer.com/email2lead/