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
rupesh ranjanrupesh ranjan 

I have entered 5-6 email Id randomly in to address. How to send mail to above email id.

I have entered 5-6 email Id  randomly in to address. 
How to send mail to above email id. 

Sample code plss
 
Best Answer chosen by rupesh ranjan
Sumeet_ForceSumeet_Force
You can use String.split which wouldnt depend upon specific number and provide an array/list of strings.

All Answers

Sumeet_ForceSumeet_Force
If thats the case, you would need to split those email IDs into individual emails and then use Messaging Class to send mails. All of this can be done using Apex Classes.(Messaging Class to be used for sending emails).
AshlekhAshlekh
Hi,

Here is a good blog on this 
http://www.sfdc99.com/2014/03/01/sending-emails-using-apex/

-Thanks
Ashlekh Gera
rupesh ranjanrupesh ranjan
TO adress will be any thing depend upon user. not for particular contact or std object email address.
To address will be dynamic out side the salesforce and it will more than 2 ya 3..
rupesh ranjanrupesh ranjan
i can't split those email IDs because it will be random more than  2or 3 
Sumeet_ForceSumeet_Force
You can use String.split which wouldnt depend upon specific number and provide an array/list of strings.
This was selected as the best answer
rupesh ranjanrupesh ranjan
Getting error in toadress just look around..
Public class SendEmail
{
    public String subject {get; set;}
    public String body {get; set;}
    public String to{get; set;}
    private contact order;
    public SendEmail(ApexPages.StandardController controller) {
    this.order = (contact )controller.getRecord();

    }
    public contact getOrder(){
      return order;
    }
    public pageReference send(){

    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    String[] toaddress = new String[]{};
    toaddress.add(to);
       email.setSubject(subject);
    email.setToAddresses(toaddress);
    email.setPlainTextBody(body);
    email.setBccSender(true);
  Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
  for ( Messaging.sendEmailResult result : res ) {

           if ( !res[0].isSuccess () ) {

               System.debug ( result  );
           }

           else{

               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
               ApexPages.addMessage(msg);
           }
       }
     
return null; 
       
}
public SendEmail(){
        body = apexpages.currentpage().getparameters().get('att');
    }


}