-
Create multiple records with one email
Hello,
I have created a feedback object in my org. I want to create a record whenever I send a mail to salesforce. So with the help of email services I generated an email address and whenever I send a mail from my Gmail to that email address a new record is created in feedback.
What is want now is to create multiple feedback.
Suppose email template format is:
Article ID: 10001;10002;10003;
Description: Link not working
For the above format what I want is to create 3 records with the same description for all 3.
Here is my code. Can you tell me what changes I have to make in it so that the above functionality is working?global class CreateTaskEmailExample implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,
Messaging.InboundEnvelope env){
// Create an InboundEmailResult object for returning the result of the
// Apex Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
String myPlainText= '';
// Add the email plain text into the local variable
myPlainText = email.plainTextBody;
// New Task object to be created
Feedback__c[] newFeedback = new Feedback__c[0];
// Try to look up any contacts based on the email from address
// If there is more than one contact with the same email address,
// an exception will be thrown and the catch statement will be called.
try {
/*Contact vCon = [SELECT Id, Name, Email
FROM Contact
WHERE Email = :email.fromAddress
LIMIT 1];*/
// Add a new Task to the contact record we just found above.
newFeedback.add(new Feedback__c(Description__c = myPlainText,
Status__c = 'Inbound Email',
Subject__c = email.subject,
IsRemainderSet__c = true,
Date__c = System.now()+1));
// Insert the new Task
insert newFeedback;
System.debug('New Task Object: ' + newFeedback );
}
// If an exception occurs when the query accesses
// the contact record, a QueryException is called.
// The exception is written to the Apex debug log.
catch (QueryException e) {
System.debug('Query Issue: ' + e);
}
// Set the result to true. No need to send an email back to the user
// with an error message
} result.success = true;
// Return the result for the Apex Email Service
return result;
}Thanks
Log In to reply.
Popular Salesforce Blogs
FlexDeploy Brings DevOps to Mule Integrations | Salesforce
You can build and test Mule Applications or APIs using Anypoint Studio very easily. But when it comes to automating deployments to your environments, with…
How Does AI In Salesforce Enable Users and Businesses to Meet Their Goals?
People who work in businesses have goals. The same goes for people who use the software. Organizations try to help their businesses meet their goals…
Quickbooks and Salesforce Integration: Rest API
In today’s business landscape, seamless integration between different software systems is essential for maximizing productivity and efficiency. When it comes to managing financial data and…
Popular Salesforce Videos
Break up Salesforce Record Detail into Tabs | Salesforce Lightning Page Layouts
In this video, Signiforce briefs about how to create an Action with a subset of fields from your object and then add this action to…
Cross Component Communication with Custom Events | Salesforce Developer Quick Takes
In this Quick Take, we will learn how to take Custom Events and apply them to a common use case. We’re first going to take…
Salesforce Development Course for Intermediate Developers
If you want to become a Salesforce developer in 2021 then watch this video, here you'll learn about some of the best Salesforce Development Course…
Popular Salesforce Infographics
How to Integrate Salesforce with External Systems
Salesforce Connect empowers you to associate Salesforce to external heritage frameworks like Oracle, SAP, DB2, Microsoft SharePoint continuously, without making a duplicate/copy of any single…
10 MUST HAVE Qualities Your Salesforce Administrator Should Have
Does your organization have a Salesforce Admin? If you use Salesforce or are in the process of implementing it, the role of Salesforce Admin is…
What is Salesforce Architecture?
Have you ever wondered that what is so special about Salesforce? How does it manage to accomplish so much in such a less time? Well,…