-
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

What does a Salesforce Professional Do? Exploring Salesforce Roles and Profiles
There are a number of articles and blogs out there discussing the demand, the salaries, or the need for certification for a Salesforce professional. But…

Import and Export Data from Salesforce using Talend
Talking about Salesforce the transfer of data does not fall under a very cumbersome category. There are myriad tools like Salesforce Dataloader.io which have rather…

Understanding Metadata API in Salesforce | The Developer Guide
Metadata API Salesforce Metadata API is utilized to help designers in retrieving, creating, deploying, updating, or deleting the customized information. It can be something that…
Popular Salesforce Videos
Get Started with Admissions Connect | Salesforce Tutorial
Ready to simplify the application process and streamline the work of your admissions professionals? Enter: Admissions Connect! This is the purpose-built product built natively on…
Salesforce Tower San Francisco Virtual Community Tour
Wherever you are around the world, join us for a virtual tour of Salesforce Tower San Francisco, our global headquarters. Together, we’ll take a walk…
Can Non-IT People Make their Career In Salesforce?
This video focuses on if non-IT people can make a career in Salesforce. Salesforce is a customer relationship management (CRM) platform that offers various roles…
Popular Salesforce Infographics

5 Advantages of Using Salesforce for Your Business
Salesforce is a customer relationship management (CRM) platform that offers a wide range of features and benefits for businesses of all sizes. Here are five…

Leverage Nonprofit trends with Salesforce Nonprofit Cloud
Salesforce Nonprofit Cloud is a suite of tools designed to help nonprofits take advantage of the latest trends and technologies. With the Nonprofit Cloud, your…

In marketing, Can We Achieve What We Can’t Measure? | Salesforce
Metrics in marketing are always evolving and we can all learn more about them from our peers. Let’s look at where marketers are spending their…