Email Parsing with apex class

Anybody having knowledge regarding the Email Parsing??
I have a requirement that i receive data from email and i need to split it.
for ex: *Category : (Some Data)
*Type : (Some Data)
I need to separate the data accordingly and store the same.


Once you have your inbound email service set up, which is pretty easy to do if you just follow the docs, you’ll need to write an inbound email handler class to process inbound email objects using the inbound email class.

You’ll then want to set up a means to split your email body. Unless there’s a common delimiter that you know you can count on, you’ll want to use the Matcher Class along with RegEx to separate the data strings into Capture Groups for further processing. I’ve linked you to a site that will help you set up your RegEx expression.

Once you have the capture groups (strings), you can use various string methods as required from the string class to do what you need to get your data, such as splitting the strings using the colon following Category: or whatever strategy you feel makes the most sense to you then assigning the value to your field or a list for later dml processing.

There are plenty of examples of inbound email handlers for processing various types of data if you google them, so I won’t include any code here.

Source : Link , Question Author : guest610 , Answer Author : crmprogdev

Leave a Comment