function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul SharmaRahul Sharma 

how can I send multiple request in a single http.send() method

Hello Support,

I am using below code for sending emails.I need to send bulk Email from Salesforce.but here I am facing Error with
Too many future calls: 11
Can you please let me know how can I send multiple request in a single http.send() method.

 //send the email
    @future (callout=true)
     public static void SendElasticEmailBulk(String userName, String APIKey, String fromEmail,
        String fromName, String subject,list<String> lstEmailWithMessage)  {
        Http http = new Http();
        for(string strEmailMessage :lstEmailWithMessage){
            string[] arrSplitResult = strEmailMessage.split('#',2);
           
            HttpRequest req = new HttpRequest();
            HTTPResponse res;
            req.setEndpoint('https://api.elasticemail.com/mailer/send')
;
            req.setMethod('POST');  
          
            try {    
                //Construct the data
                String data = 'userName=' + userName;
                data += '&api_key=' + APIKey;   
                data += '&from=' + fromEmail;
                data += '&from_name=' + fromName;
                data += '&subject=' + EncodingUtil.urlEncode(subject, 'UTF-8');
                data += '&body_html=' + EncodingUtil.urlEncode(arrSplitResult[1], 'UTF-8');
                data += '&reply_to='+Label.Inbound_Email;
                data += '&to=' + arrSplitResult[0];//Email Address
       
                req.setBody(data);
                http.send(req);
            }
           
            catch(Exception e) {
                Alert.Emailmessage('Error on Execption'+string.valueOf(e));           
            }
        }

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma
The code was written inside a for loop due to which future method limits were crossed.
Thanks for your time board.

All Answers

Bhup_IndoreBhup_Indore

I am also facing same issue. Can any one help us.

 

Bhup

Rahul SharmaRahul Sharma
The code was written inside a for loop due to which future method limits were crossed.
Thanks for your time board.
This was selected as the best answer
Bhup_IndoreBhup_Indore

Thanks for Reply,

 

But I need send more then 10 request from salesforce is it possible?