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 Siebel Batch’);
messageBody = ‘<html><body>Hi ‘ + member.Name + ‘,<br>Welcome to Sweet 16.<br><br><b>Regards,</b><br>Magulan D</body></html>’;
mail.setHtmlBody(messageBody);
}
//Email notification
if(trigger.isUpdate)
{
mail.setSubject(‘Updates in your details’);
messageBody = ‘<html><body>Hi ‘ + member.Name + ‘,<br>Changes have been made to your details. <br><br>Contact administrator if you are not responisble.</body></html>’;
mail.setHtmlBody(messageBody);
}
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
Welcome message and update notification trigger in Salesforce
Sample Code: