+ Start a Discussion
Sayan Mukherjee 7Sayan Mukherjee 7 

how can i send a email using apex ?

Devanshu soodDevanshu sood
public with sharing class send_email {

    public PageReference sendmail() {
    Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    message.toAddresses = new String[] { 'test@gmail.com' };
    message.subject = 'Subject Test Message';
    message.plainTextBody = 'This is the message body.';
    Messaging.SingleEmailMessage[] messages =   new List<Messaging.SingleEmailMessage> {message};
    Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
        return null;
    }

}

This is simple class for sending email,you can use it with vf or trigger
Devanshu soodDevanshu sood