-
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
Salesforce Offers Artificial Intelligence To Ramp Up Small Businesses!
AI or Artificial Intelligence is here to stay and stay for quite a longer period than we might have apprehended. It continues to empower the…
Choosing the Right Salesforce Implementation Consultant and Partner: A Comprehensive Guide
Implementing Salesforce in a business to streamline its performance is a decision every e-commerce business makes to make its CRM project a real success. However,…
Top 7 Salesforce Sales Dashboards for 2022-2023
Salesforce Sales dashboards are great tools for taking full advantage of CRM capabilities. The platform allows you to collect all the information about your company,…
Popular Salesforce Videos
How to use Salesforce Data to drive producivity and greater data capture
How do you encourage and drive better quality data entry into Salesforce by Salespeople? How do you use that data to drive productivity and proactive…
Non-technical But Want to Build Career in Salesforce?
In this video Shrey gave the answer to the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…
Difference between B2B, B2C and B2B2C Salesforce Commerce Cloud?
There is a lot of buzz about the Salesforce commerce cloud and its effective offerings. Let’s dive deep into the world of Salesforce and the…
Popular Salesforce Infographics
Salesforce – The Future of Digital Transformation | An Infographic
Salesforce has been coined as the world’s top CRM company and customer company. It has been soaring high in the clouds, so let’s brush through…
Benefits of Integrating Tableau with Salesforce
Tableau Integration with Salesforce helps businesses gain a multitude of advantages. The true power of Salesforce CRM is felt only when business users can analyze…
How is Salesforce Benefiting Businesses?
Salesforce is one of the top cloud-based CRM software for service, marketing, and sales. It helps in creating a more meaningful relationship with the customers.…