+ Start a Discussion
kishore64kishore64 

Email to Lead Problem

Hi every one,
       I have a problem regarding Email to Lead i.e, when ever the customer sending an email to salesforce then the lead is automatically  created in our organization. But the total lead details goes to Description field but i don't want like that .My requirement is, In the mail customer sends like this
  Name : kishore
  Company : XXXXXXX
Industry : Banking

I want this details directly in that partucular fields. So how can i acheive this one Please help me out........

Advance Thank you.
magicforce9magicforce9
Hi,

There are two ways do it..

1. You can download this free app from AppExchange https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016cRqEAI  detailed install instructions here (https://sites.secure.force.com/appexchange/servlet/servlet.FileDownload?file=00P30000003TbnhEAC)

2. You'll need to write email services for this..Since you have a custom requirement, I'm not sure if the above app will be a best fit for you..So you need to know some apex to get started with this option. You can find a lot of resources online..but here is nice blog post on how to write an email service : http://blog.jeffdouglas.com/2010/03/12/writing-an-inbound-email-service-for-salesforce-com/

Hope it helps..!

Thanks,
Mohammed
kishore64kishore64
Hi magicforce9,

           I searched in google a lot , i am not get any thing related to this requirement  that's reason i posted here. Any body have any idea regarding this requirement please  suggest me.....

1st way i did but the total email body goes to  description field  and i am customizing some code but the code is not working so how can i overcome this problem .
magicforce9magicforce9
Can you post the code that you've written for your email services..Also the complete format in which the email will be received + can you tell if its going to be a  fixed format or it will change from email to email
kishore64kishore64
Here i am trying with this code and it's also taken from  the google but i added some more fields in this code...


global class CreateLead 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;

    // Check for existing leads with this email address  
    Lead[] leads = [SELECT Id, Name, Email
                      FROM Lead
                      where Email =: email.fromAddress];

    if (leads.size() == 0) {
      // New Lead object to be created - set LastName and Company to
      // dummy values for simplicity
      Lead newLead = new Lead(Email = email.fromAddress,
        LastName = 'From Email',
        Company = 'From Email',
        Country='From Email',
        Industry='From Email');
      // Insert a new lead
      insert newLead;   

      System.debug('New Lead record: ' + newLead );  
    } else {
      System.debug('Incoming email duplicates existing Lead record(s): ' + leads );   
    }

    // 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;
  }
}