Sample Trigger:
trigger sendEmail on Employee__c (after insert) {
List<Attachment> listAttachments = new List<Attachment>();
for(Employee__c e : trigger.new) {
Attachment a = new Attachment();
a.ParentId = e.Id;
a.Name = e.Name + Date.Today();
a.ContentType = ‘text/plain’;
a.Body = Blob.valueOf(e.Name + ‘ is added successfully’);
listAttachments.add(a);
}
insert listAttachments;
}