Skip to content

Instantly share code, notes, and snippets.

@sudikrt
Created October 20, 2019 10:12
Show Gist options
  • Save sudikrt/4a3e1799fadc66c03485cba41b026bf2 to your computer and use it in GitHub Desktop.
Save sudikrt/4a3e1799fadc66c03485cba41b026bf2 to your computer and use it in GitHub Desktop.
global class EmailToLead implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail (Messaging.InboundEmail email, Messaging.InboundEnvelope envelop ) {
Messaging.InboundEmailResult res = new Messaging.InboundEmailResult ();
Lead leadData = new Lead ();
leadData.LastName = 'Email TO lead';
leadData.Company = 'Email2Lead';
leadData.Email = email.fromAddress;
leadData.TTSApp__StartDate__c = System.now();
leadData.TTSApp__EndDate__c = System.now().addDays(10);
try {
DataBase.insert (leadData);
} catch (Exception e) {
System.debug('Email2Lead exception :' + e);
}
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment