You need to sign in to do that
Don't have an account?
Email service
i am creating Email Service class my requirement is when task status is completed then email will sent to assign contact persion emai id...so.....i am new to Email service concept.please help me...here is my code
global class emailservice implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,
Messaging.InboundEnvelope env){
// Create an inboundEmailResult object for returning
// the result of the Force.com Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
task te=[select id,status,whoid from task limit 1];
Contact c=[select id,lastname,Account.Name,email from contact where id=:te.whoid];
String myPlainText = 'I spoke with '+c.lastname+ 'today from '+ ' '+c.account.name +' '+'about the latest proposal.';
// Add the email plain text into the local variable
try
{
myPlainText = email.plainTextBody.substring(0, email.plainTextBody.indexOf('<stop>'));
}
catch (System.StringException e)
{
myPlainText = email.plainTextBody;
System.debug('No <stop> in email: ' + e);
}
// Set the result to true, no need to send an email back to the user
// with an error message
if(te.status=='completed')
result.success = true;
// Return the result for the Force.com Email Service
return result;
}
}
Hello,
I am wondering why you need to write email service for this requirement as this can be easily achieved by creating a workflow on Task object with
Rule Criteria Task: StatusEQUALSCompleted and Evaluation Criteria Evaluate the rule when a record is created, and every time it’s edited
Finally in workflow action you can choose Email alert.