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
Subhrajyoti NathSubhrajyoti Nath 

sending custom email format

Hi guyz,

When i will click the send button on my visulaforce page i want to send an email to the respective recepient in this formatUser-added image

Please help me to accomplish this. Thanks.
 
Ajay K DubediAjay K Dubedi
Hi
add the method to your controller and define the action for your button
   
public PageReference send() {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
        Datetime cDT = System.now();
        string LongDate = cDT.format('EEEE, MMMM d, yyyy hh:mm:ss');
        system.debug('+++++++++++++++++++'+LongDate);
           // Sets the paramaters of the email
        string body ="Add your body here";
        email.setSubject( subject );//Add your subject here
        email.setToAddresses( toAddresses );//Add your reciepients email address here
        email.setPlainTextBody( body +LongDate);//Define your body here
    
        // Sends the email
        Messaging.SendEmailResult [] r = 
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});   
        
        return null;
    }
}

Thanks.