trigger memberInviteNotify on Member__c (after insert,after update)
{
for(Member__c member:trigger.New)
{
String[] toAddresses = new String[] {member.E_Mail_Id__c};
String messageBody;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toAddresses);
//Email invitation
if(trigger.isInsert)
{
mail.setSubject('Welcome to Sweet 16');
messageBody = 'Hi ' + member.Name + ', Welcome to Sweet 16';
mail.setHtmlBody(messageBody);
}
//Email notification
if(trigger.isUpdate)
{
mail.setSubject('Updates in your details');
messageBody = 'Hi ' + member.Name + ', Changes have been made to your details. Contact administrator if you are not responisble.';
mail.setHtmlBody(messageBody);
}
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
No comments:
Post a Comment