Salesforce Developers Blog

Create Ideas from Emails

Avatar for Rasmus MenckeRasmus Mencke
I have built an example of how you can use Salesforce Ideas and create new ideas from emails. Using Force.com Email Services to allow people to send emails and convert the emails into new Ideas.
June 19, 2008
Listen to this article
0:00 / 0:00

I have built an example of how you can use Salesforce Ideas and create new ideas from emails. Using Force.com Email Services to allow people to send emails and convert the emails into new Ideas.

Taking the subject line as the title of the Idea and use the body of the email as the content for the Idea.

The main class for creating the Email Services is below.

1Global class IdeasSample implements Messaging.inboundEmailHandler{ Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,  Messaging.InboundEnvelope env ) {  Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();  // Create the new Idea from the incoming email        createIdea(email.subject, email.plainTextBody, env.fromAddress);     // 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;}
1Creating the Idea takes the subject, text body of the email and the from email address as arguments
1public static Idea[] createIdea(String IdeaTitle, String ideaBody, String fromEmail) {  // instance of a new Idea  Idea[] newIdea = new Idea[0];  // create a new Idea  newIdea.add(new Idea(Body = ideaBody,            		Title = IdeaTitle));   insert newIdea;            sendEmail(fromEmail,newIdea);    return newIdea;     }
1To see the full code sample check this out