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
Sascha DeinertSascha Deinert 

Inbound eMail Handler - monitor incoming mails


I add a inbound email handler into my org to add a new record in a custom object (bt).

Sometime the mails are not processed and I don't know why. Is there a way to check the incoming mails in Salesforce?

can I enter a line in the code where the process should begin and end? Because sometimes is some text before or after the relevant points.
global class btFromEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    bt__c C = new bt__c(); 
        if(email.plainTextBody != Null && email.plainTextBody != '') {
            String[] emailBodyRows = email.plainTextBody.split('\n');
            for (String bodyRow:emailBodyRows) {
                String[] rowContents = bodyRow.split(':');
                String label = rowContents[0].trim();
                String value = rowContents[1].trim();
                switch on label {
                    when 'Firstname' {
                        c.Firstname__c = value;
                    when 'Lastname' {
                        c.Lastname__c = value;
                    when 'Birthdate' {
                         c.Birthdate__c = date.valueOf(value);
                    when 'Phone' {  
                        c.Phone_private__c = value;
                    when 'Email' {        
                        c.E_mail_private__c = value;                                        
      insert c;             
      return result;
Vishwajeet kumarVishwajeet kumar
I think their is no standard way to track incoming emails if it is not getting tagged to any record or stored. A custom solution can be built where first process in email handler should be to store the email itself and then do the processing.