You need to sign in to do that
Don't have an account?

Parse email body using strings to create case and populate it's fields
Hello Everyone,
Need a help with email services. I'm trying to create cases throgh emails by using InboundEmailHandler. Our customers have a predefined email format (please check the screenshot). Once the email is sent to our organization, a case has to be created but it shouldn't just dump the email body in the description field. Each of the value in the email belongs to a particular field of case object. I've researched online and found out that String.Split is the way to go. However, I'm having trouble to write the code (still an amateur at Apex). Can any one please help me how to split the lines of email body and assign them to fields in the case object. Please explain it through w.r.t to the email body provided. Thank you!
For ex: Problem Description infromation should be popualted in case descriton field
Warranty information should be populated in product_warranty__c custom field.
P.S: We only get emails in text format. No html is involved.

Need a help with email services. I'm trying to create cases throgh emails by using InboundEmailHandler. Our customers have a predefined email format (please check the screenshot). Once the email is sent to our organization, a case has to be created but it shouldn't just dump the email body in the description field. Each of the value in the email belongs to a particular field of case object. I've researched online and found out that String.Split is the way to go. However, I'm having trouble to write the code (still an amateur at Apex). Can any one please help me how to split the lines of email body and assign them to fields in the case object. Please explain it through w.r.t to the email body provided. Thank you!
For ex: Problem Description infromation should be popualted in case descriton field
Warranty information should be populated in product_warranty__c custom field.
P.S: We only get emails in text format. No html is involved.
What I would do is use an online regex editor (such as regexr (https://regexr.com/)) until you've got a Regular Expression ("regex") that matches the text you're looking for. For example, you might look for text that begins with "Problem Description" and ends when it finds "Assignment", assuming the emails always follow that format.
Once you have your regular expression, you can use the Pattern Class to do this automatically to identify your key text.
Repeat this process for any specific pieces of text you need to identify.
You can use the following for your requirements
substringBetween(open, close) - Returns the substring that occurs between the two specified Strings.
It would work a little like this: Documentation link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#!)
I want to implement the same for my Lead object.
I want to map the Title,First Name, Main Phone no., Mobile Phone no., Subject and Query Detail.
Were you able to come up with a solution to this request?