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
DJ 367DJ 367 

Email to salesforce with custom Email id

Hello All,

I have an email id lets say abc@gmail.com, My requirment is whenever any email is send to abc@gmail.com it should record into email object or any custom object with the attachment. This is urgent , can someone please help me.

Thanks
Best Answer chosen by DJ 367
DJ 367DJ 367
I resolved this setup--> Email services , created a email service and called this class into it.

All Answers

Raj VakatiRaj Vakati
You can use Email Message or Your can create Email inbound  handler and create an customobject from there

Email Handler


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

Email Message 

https://help.salesforce.com/articleView?id=000239922&type=1
DJ 367DJ 367
Hi Raj,

Thanks for your reply. I have a question here, how can i call this in visualforce page. Like I want to display all the received email into visualforce page. Thanks
DJ 367DJ 367
Hi @Raj Vakati

Here is my code, how can I display this into vf page. Thanks 
 
global class CreateTaskEmailExample implements Messaging.InboundEmailHandler {
 
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){
                                                           
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();                          
        String myPlainText= '';
        myPlainText = email.plainTextBody;
                                   
        List<Selected_Email__c> lstReceivedEmails = new List<Selected_Email__c>();
        
        lstReceivedEmails.add(new Selected_Email__c(
            From__c = email.fromAddress,
            Email_Description__c = email.subject,
            Received_Date_Time__c = System.now()
        ));
        
        insert lstReceivedEmails;
        result.success = true;
        return null;
                                                           
    }
                                                           
}

 
DJ 367DJ 367
I resolved this setup--> Email services , created a email service and called this class into it.
This was selected as the best answer