You need to sign in to do that
Don't have an account?

emai to apex
Hi
I have an student application, there is a college website with a page for request information.A student enters the info in the page , submits it and then the data is sent to database.I do not have to do anything here.Now, an email is sent from an email address of the database to the admission office with the student info which he entered while ago...like first name , last name email address...etc....I need to write an email to apex...such that..if the student record is present create a task , if not present create a record and task...Here , student record is the contact record....Now, can we do this using email to apex...if yes how...??/ If no, then how can I do this..?? Any ideas, suggestions are welcome....
thank you
Yes, you can do this by creating an Email Service and having your system send the email to the service. You need to write an Apex class that the service will use to create a contact and task. Watch this video and read the docs to see how it all works:
http://wiki.developerforce.com/index.php/Tech_Talk_Series:_Introduction_to_the_Email_Services_on_Force.com
http://wiki.developerforce.com/index.php/Force.com_Email_Services
All Answers
Yes, you can do this by creating an Email Service and having your system send the email to the service. You need to write an Apex class that the service will use to create a contact and task. Watch this video and read the docs to see how it all works:
http://wiki.developerforce.com/index.php/Tech_Talk_Series:_Introduction_to_the_Email_Services_on_Force.com
http://wiki.developerforce.com/index.php/Force.com_Email_Services
Hi
I have been trying to create a contact record once the email is received with an email content filled with the student information.When I see the debug logs , I see the error
/**
* Email services are automated processes that use Apex classes
* to process the contents, headers, and attachments of inbound
* emails.
*/
global class Task implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(
Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result =new Messaging.InboundEmailresult();
// Captures the sender's email address
//String emailAddress = envelope.fromAddress;
// Retrieves the sender's first and last names
//String firstname = email.fromname.substring(0,email.fromname.indexOf(' '));
//String lastname = email.fromname.substring(
//email.fromname.indexOf(' '));
// Retrieves content from the email.
// Splits each line by the terminating newline character
// and looks for the Contact of the phone number and city
Contact[] newContact = new Contact[0];
String[] emailBody=email.plainTextBody.split('\n', 0);
String firstname=emailBody[0].substring(8);
String lastname=emailBody[1].substring(7);
String Emailaddress=emailBody[2].substring(6);
String address=emailBody[3].substring(5);
String city=emailBody[4].substring(4);
String state=emailBody[5].substring(3);
String area_of_interest=emailBody[6].substring(2);
String phoneNumber = emailBody[7].substring(1);
String HighSchoolGraduationDate=emailBody[8].substring(0);
// Creates a new contact from the information
// retrieved from the inbound email
try
{
newContact.add(new Contact(FirstName = firstname,
LastName = lastname,
email = EmailAddress,
Phone = PhoneNumber,
MailingStreet=address,
MailingCity = city,
MailingState=state,
EnrollmentrxRx__Program_of_Interest__c = area_of_interest,
High_School_Grad_Year__c=HighSchoolGraduationDate));
insert newContact;
}
catch (System.DmlException e)
{
System.debug('ERROR: Not able to create contact: ' + e);
}
// Sends the email response
//myContact = createContact.newContact
//(firstname, lastname, EmailAddress, PhoneNumber);
// Sends an email notification to the applicant
//emailHelper.sendEmail(myContact[0].id);
return result;
}
}
I need help....I am trying to fix this but in vain...