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? Commented Aug 17, 2017 at 14:38
  • Yes only amount will change in the above template Commented 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. Commented Aug 17, 2017 at 18:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.