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
Anshuman ParhiAnshuman Parhi 

Create ‘Account’ object record based on email sent to the Salesforce. Email will contain the account details. [Hint: Use Email Services]

Any solution
Maharajan CMaharajan C
Hi Anushuman,

Yes you can do this with help of Email Servica and InboundEmailHandler Interface Apex Class.

Please use the below blog and dev guide for your reference. Code sameples are available in the below blogs just follow.

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_email_inbound_inbound.htm

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_inbound_using.htm

http://sfdcsrini.blogspot.com/2014/11/inbound-email-service-in-salesforce.html

https://astreait.com/Email-Services-In-Salesforce/

http://amitsalesforce.blogspot.com/2016/11/apex-email-service-inboundemail-object.html



Note:  You can use your own email address also for toaddress. For this you have to add the unique Email id generated from the Salesforce email service in your email account forward IMAP/POP settings.

Thanks,
Maharajan.C
Anshuman ParhiAnshuman Parhi
Hello
 Can anyone give the code and logic which i have to apply
PARNAPALLI ASHOKKUMARPARNAPALLI ASHOKKUMAR

Create ‘Account’ object record based on email sent to the Salesforce. Email will contain the account details. [Hint: Use Email Services]

global class CreateAccountEmailService implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(
    Messaging.InboundEmail email,
        Messaging.InboundEnvelope envelope){
            messaging.InboundEmailResult result=new Messaging.InboundEmailResult();
            
            String plainTextBody=email.plainTextBody;
            System.debug(plainTextBody);
            
            Account acc=new Account();
            Acc.Name=plainTextBody.substringBetween('<Name>','</Name>');
            Acc.AccountNumber=plainTextBody.substringBetween('<AccNum>','</AccNum>');
            Acc.Staus__c=plainTextBody.substringBetween('<Status>','</Status>');
            
            database.SaveResult insertAccountRecord=database.insert(Acc);
            
            return result;
        }
    }


create a email service

I hope Its helpful.