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
Yao Lin 8Yao Lin 8 

Invalid Type in Inbound Email Service

Hello, 
I am new with Apex and tried to create an inbound email service in salesforce. 
First of all, I receive an email. I need to look for a serial number on the email content to match the serial name which is already a record in Salesforce. If email bady contains "FULL OUT", it updates field Status (API: Status__c) on a custom object "Container(API: Container__c)".
How can I write the Apex code? Please help.

I don't know how to write code to look for tried to write a simple code to insert the record, received 2 error messages: 
1. line 5: invalid type: Container
2. line 6: Method does not exist or incorrect signature: void containder() from the type UpdateContainer()
global class UpdateContainer implements Messaging.InboundEmailHandler{
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope){
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        string containerName = email.fromName;
        Container container = new Container(Name=containerName);
        insert container();
        return null;
    }
}

 
Best Answer chosen by Yao Lin 8
David @ ConfigeroDavid @ Configero
You need to find your standard or custom object you are trying to insert, and get the API name to use, not 'Container'.  If your custom object is named Container, the API name is most likely Container__c, so try this:
Container__c container = new Container__c(Name = containerName);



Also on line #6 () is used for calling methods, and has nothing to do with variables.  Assuming you properly initialized a variable named 'container', then you just do:
insert container;

Please mark this as the correct answer if it helped you!

All Answers

David @ ConfigeroDavid @ Configero
You need to find your standard or custom object you are trying to insert, and get the API name to use, not 'Container'.  If your custom object is named Container, the API name is most likely Container__c, so try this:
Container__c container = new Container__c(Name = containerName);



Also on line #6 () is used for calling methods, and has nothing to do with variables.  Assuming you properly initialized a variable named 'container', then you just do:
insert container;

Please mark this as the correct answer if it helped you!
This was selected as the best answer
Yao Lin 8Yao Lin 8
It works! Thanks a lot, David!
Any chance you know how to look for a serial number on the email content that matches a record on Salesforce?
David @ ConfigeroDavid @ Configero
If you are able to mark the best answer for this solution and post a new question for your email content issue, I'd be happy to help.  It helps the people giving answers and also the community when answers are marked as valid, so they are able to find solutions to pre-existing problems others have had.

Make sure you provide as much details and information as possible on the new question so I or someone else can help you more efficiently/faster.

Thanks!
Yao Lin 8Yao Lin 8
Of course. I will post a new question.