Create Ideas from Emails

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.

Global 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;}
Creating the Idea takes the subject, text body of the email and the from email address as arguments
public 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;     }    
To see the full code sample check this out
tagged Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • http://www.successforce.com Kingsley Joseph

    Nice!

  • Jamie Grenney

    Very Cool Rasmus. It is kind of like American Idol. You could be in front of your TV and email an idea or even cast a vote.
    Eventually you might take this one step further and create some logic to check for similar ideas. The customer might get an auto-response email saying… “Thanks for your submission. We found a couple similar ideas. Do you still want to submit your idea or would you rather cast a vote for one of the ideas below?”

  • Mark

    Might be a stupit comment, but what is the email address you are meant to send the emails to?