-
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 Developers Guide: Build Your App With Salesforce AppExchange
Are you looking to start building Salesforce apps? You probably have a comprehensive understanding of how Salesforce works and know that there are many things…
Switching from MS Dynamics to Salesforce | Learn Here
Introduction Talking about a CRM both MS Dynamics and Salesforce are great platforms to work on. But with the advancement and upgradation in technological development,…
Popular Salesforce Videos
Salesforce Lightning Training - Creating Hello World Lightning Component
Data Loader is a utility to perform bulk database operation. Recently Salesforce has changed the way data loaders need to be install. I explain end…
Easy Way to Learn Salesforce | How to Learn Salesforce Step by Step
In this video on Easy Way to Learn Salesforce, you will learn introduction to Salesforce, how to learn Salesforce easily, Salesforce as Career and Growth,…
Why iCompliance Trusts TechForce Services for Salesforce Managed Services | Client Testimonial
At iCompliance, delivering trusted AFSL compliance services requires seamless operations and efficient technology. That’s why they turned to TechForce Services for Salesforce Managed Services. In…
Popular Salesforce Infographics
How to Choose the Right Salesforce Partner
Choosing the right partner is a key factor that could make or break your project’s success. Salesforce is a mighty CRM platform, and that’s why…
The 6 Greatest Benefits of CRM Platforms | Salesforce CRM
A CRM platform helps companies target different audiences, set scores and alerts based on an individual lead or customer’s activity, proactively work with contacts and…
Benefits of Salesforce Commerce Cloud
As the online marketplace is continuously growing in the global economy, it's important to have a feature-loaded and scalable e-commerce platform. Salesforce commerce cloud is…