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
LloydSLloydS 

Parsing email body to populate case fields

We use an appexchange product for case handling (Email to Case Premium). E2CP in turn uses an email service to process the cases that come.

 

We have incoming emails generated by a non-SFDC connected form. The from email address is related to the server of the 3rd party service we're using for that application. The body of the email contains about 20 pieces of information including first and last name, email address, phone, and other.

 

We'd like to parse the body of the email to populate standard and custom case fields. And if the person is not already a contact, we need to make them such. How do we do this?

 

I found something in the cookbook at http://www.salesforce.com/us/developer/docs/cookbook/Content/messaging_inbound_retrieving_info.htm that seams to apply. Correct? Do I need to do anything differently because of the existing email service being used to create cases? If the referenced code is the right way of doing this, how do I identify the specific pieces of information we need.

 

For example, 

String phoneNumber = emailBody[0].substring(6);

In this case, what does emailbody[0].substring(6) referring to? Is emailBody[0] referencing the first line of the body? And so emailBody[1] would be referencing the 2nd line? What about substring?

 

Thanks.

 

bob_buzzardbob_buzzard

In the cookbook example you've linked to, emailBody is an array created by splitting the real email body up by newline characters.

 

Thus 

 

emailBody[0].substring(6);  

 

is extracting the contents of the first line of the email (which equates to the zeroth array element), starting at the sixth character.  This means that the email is similar to:

 

Phone:123456123 

City:Las Vegas

 

 

and that line of code is stripping the 'Phone:' from the first line of the email to get the actual phone number.  The next line is stripping the 'City:' from the second line. 

 

Message Edited by bob_buzzard on 03-17-2010 01:36 AM