+ Start a Discussion
siva@shiva.comsiva@shiva.com 

SINGLE_EMAIL_LIMIT_EXCEEDED, Failed to send email: []

i am traing to send mail to contact email ....but it give an error....please help me

Puja_mfsiPuja_mfsi

Hi,

Single email messages sent with the sendEmail method count against the sending organization's daily single email limit. When this limit is reached, calls to the sendEmail method using SingleEmailMessage are rejected, and the user receives a SINGLE_EMAIL_LIMIT_EXCEEDED error code. However, single emails sent through the application are allowed.
 
Edition Address Limit per Mass Email
Professional -  250
Enterprise Edition - 500
Unlimited Edition - 1,000
 
 
Please let me know if u have any problem on same and if this post helps u give KUDOS by click on star at left.
siva@shiva.comsiva@shiva.com

here is my code ...please check it

trigger createactivity on Task (before insert,after insert,before update,after update) {
if(trigger.isbefore)
{
    if (Trigger.isinsert) {
 
     for(task t:trigger.new){
      if(t.status=='completed'){
          sendmailto();    
       }
      }
    }

}

if(trigger.isafter){

if(trigger.isinsert)
{
 for(task t:trigger.new){
      if(t.status=='completed'){
       sendmailto();    
       }
      }
}
 if (Trigger.isupdate) {
 
     for(task t:trigger.old){
      if(t.status=='completed'){
       sendmailto();    
       }
      }
    }

}
public void sendmailto()
{
     Contact c=[select id,lastname,Account.Name,email  from contact limit 1];
     List<id> contactids;
     
     string []to=c.email.split(':',0);
     system.debug('************************************'+to);
     if(c.email<>null)
     {
     Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
     
     email.setToAddresses(to);
      //email.setTargetObjectId(c.id);  
      email.setSubject('this will be the task subject');
      email.setplainTextbody('I spoke with '+c.lastname+ 'today from '+c.account.name +'about the latest proposal.');
      messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{email});
      }
          
       else
        {
            Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
            String[]  toAddresses = new String[] {'sivasalesforce.com@gmail.com'};
            mail1.setToAddresses(toAddresses);
            mail1.setplainTextbody('Invalid mail id'+c.email);
            //Messaging.sendEmail(new Messaging.SingleEmailMessage [] {mail1});
            messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{mail1});

       }
     
}
}