• Kashif Ali 56
  • NEWBIE
  • -1 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi

following is my code:

public PageReference sendEmailMethod(){
        List<Messaging.SingleEmailMessage> message = new List<Messaging.SingleEmailMessage>();
        try{
            update email;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.message
            (ApexPages.severity.Warning,'An error occured while sending email'+e));
            return null;
        }
        String body = '';
        for(integer i=0;i<wrapperBooks.size();i++){
            if(wrapperBooks[i].isSelected == true){
                Messaging.SingleEmailMessage msg = Messaging.renderStoredEmailTemplate(email.Id, wrapperBooks[i].book.Author__r.Id, wrapperBooks[i].book.Author__r.Id);
                msg.setTargetObjectId(wrapperBooks[i].book.Author__r.Id);
                msg.setSaveAsActivity(false);
                message.add(msg);
            }
        }
        system.debug('--->'+message.size());
        System.debug('You have made ' + Limits.getEmailInvocations() + ' email calls out of ' + Limits.getLimitEmailInvocations() + ' allowed');
        try{
            Messaging.sendEmail(message);
            System.debug('Email sent Success fully to:'+message.size());
            PageReference ref = new PageReference('/apex/booksDetails');
            ref.setRedirect(true);
            return ref;
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message
            (ApexPages.severity.Warning,'An error occured while sending email'+e));
            return null;
        }
    }

Can someone tell me how to fix this. I want to send bulk emails. I am in my developer org.
 

Hi

following is my code:

public PageReference sendEmailMethod(){
        List<Messaging.SingleEmailMessage> message = new List<Messaging.SingleEmailMessage>();
        try{
            update email;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.message
            (ApexPages.severity.Warning,'An error occured while sending email'+e));
            return null;
        }
        String body = '';
        for(integer i=0;i<wrapperBooks.size();i++){
            if(wrapperBooks[i].isSelected == true){
                Messaging.SingleEmailMessage msg = Messaging.renderStoredEmailTemplate(email.Id, wrapperBooks[i].book.Author__r.Id, wrapperBooks[i].book.Author__r.Id);
                msg.setTargetObjectId(wrapperBooks[i].book.Author__r.Id);
                msg.setSaveAsActivity(false);
                message.add(msg);
            }
        }
        system.debug('--->'+message.size());
        System.debug('You have made ' + Limits.getEmailInvocations() + ' email calls out of ' + Limits.getLimitEmailInvocations() + ' allowed');
        try{
            Messaging.sendEmail(message);
            System.debug('Email sent Success fully to:'+message.size());
            PageReference ref = new PageReference('/apex/booksDetails');
            ref.setRedirect(true);
            return ref;
        }
        catch(Exception e){
            ApexPages.addMessage(new ApexPages.message
            (ApexPages.severity.Warning,'An error occured while sending email'+e));
            return null;
        }
    }

Can someone tell me how to fix this. I want to send bulk emails. I am in my developer org.