0

I have a requirement to create case for specific subject email.I wrote an email service working well.

But now i try to capture some values from email body and need to updatein specific field.

Like

Invoice Total Amount: 658.81 USD(includes taxes, shipping and handling)

I will try to use like emailBody[0].substring(22);

But, amount value will change accordingly.So i try to use string functions like ends with But i'm not able to achieve.

2
  • The subject will always be the same? Only the amount will change? Aug 17, 2017 at 14:38
  • Yes only amount will change in the above template
    – Pavan tej
    Aug 17, 2017 at 14:39

1 Answer 1

1

If you're sure the subject will never change except for the amount, you should use the substringBetween(open, close) method of the String class. You can use the ':' character as open tag and 'USD' as close tag.

Then, you can use the trim() method of the String class to remove any leading or trailing white space characters.

Here's the code:

String amountStr = subject.substringBetween(':', 'USD').trim();
1
  • Works as expected mine is currency field converted to decimal.
    – Pavan tej
    Aug 17, 2017 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.