You need to sign in to do that
Don't have an account?
suji srinivasan
how to use vfcomponent as attachment in Apex trigger email template?
Hi , if salarystatus picklist is credited in salary object .i need to send email to the respective employees official mail id and add cc to the personal mail id of employees . can anyone guide me?
if (trigger.isafter && trigger.isupdate) {
for(Salary_Detail__c Sa:trigger.new){
if( sa.salary_status__c=='Credited'){
//public PageReference sendPdf(){
PageReference pdf = Page.payslip;//mail_pdf is the name of vf page
pdf.getParameters().put('email',email);
// goToNextPage('email');
Blob body;
try{
body = pdf.getContent();
}catch(VisualforceException e){
body=Blob.valueOf('Some text');
}
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setContentType('application/pdf');
attach.setFileName('payslip.pdf');
attach.setInline(false);
attach.Body = body;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email });
mail.setSubject('Payslip');
mail.setHtmlBody('Please Find the payslip for the month');
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Email with PDF sent to '+email));
return null;
//}
}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(sa.userinfo.getuseremail());
mail.setToAddresses(sendTo);
//mail.setReplyTo('test@gmail.com');
mail.setSenderDisplayName('HR Team');
List<String> ccTo = new List<String>();
ccTo.add();
mail.setSubject('Payslip for the month');
String body = '<html><body>Dear ' + sa.Name + 'Please find the salary slip for the month of : Thanks ,HR Team</body> </html>
Thanks in advance
if (trigger.isafter && trigger.isupdate) {
for(Salary_Detail__c Sa:trigger.new){
if( sa.salary_status__c=='Credited'){
//public PageReference sendPdf(){
PageReference pdf = Page.payslip;//mail_pdf is the name of vf page
pdf.getParameters().put('email',email);
// goToNextPage('email');
Blob body;
try{
body = pdf.getContent();
}catch(VisualforceException e){
body=Blob.valueOf('Some text');
}
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setContentType('application/pdf');
attach.setFileName('payslip.pdf');
attach.setInline(false);
attach.Body = body;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email });
mail.setSubject('Payslip');
mail.setHtmlBody('Please Find the payslip for the month');
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Email with PDF sent to '+email));
return null;
//}
}
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(sa.userinfo.getuseremail());
mail.setToAddresses(sendTo);
//mail.setReplyTo('test@gmail.com');
mail.setSenderDisplayName('HR Team');
List<String> ccTo = new List<String>();
ccTo.add();
mail.setSubject('Payslip for the month');
String body = '<html><body>Dear ' + sa.Name + 'Please find the salary slip for the month of : Thanks ,HR Team</body> </html>
Thanks in advance