+ 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
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');
           // 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;