You need to sign in to do that
Don't have an account?
Pranav Chitrans
Send Email Attachment whenever new lead is created
I want to write the trigger in such a way that when ever new lead is getting created it automatically sens email and also attch one pdf attchment to it... I written some logic.. which is working fine when ever new lead is created it send the email but wont be able to write the logic for attchment... I am confused.. from where i have to get the attchment.. because while inserting recors.. there is no such filed of attchment... it ony comes when i save the data"Notes and attachment"/...
i had wriiten half the code of attachment but I got confused..so i left there,,..a dn one mor thing which i face the problem in line 26 in the body tag Hi, after that it shows Null (Hi Null,) why the name is not getting in email....
trigger SendAttchmnt on Lead (before Insert,before update,after Insert) { if(trigger.isInsert || trigger.isUpdate) { for(Lead l : trigger.New) { if(l.email == null) { l.addError('Email Req'); } } } if(trigger.isInsert && trigger.isAfter) { List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); for(Lead ld : trigger.New) { if(ld.Email != null) { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); List<String> toAddresses = new List<String>(); toAddresses.add(ld.Email); email.setToAddresses(toAddresses); email.setSubject('Lead generated!'); String message = '<html><body>Hi ' +ld.name + ', <br/>Lead Created '+'You are now customer of our group.<br/><br/> <b>Regards,</b><br/> Admin </body> </html>'; email.setHtmlBody(message); mailList.add(email); //Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email}); } } Messaging.sendEmail(mailList); List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>(); } }
i had wriiten half the code of attachment but I got confused..so i left there,,..a dn one mor thing which i face the problem in line 26 in the body tag Hi, after that it shows Null (Hi Null,) why the name is not getting in email....
one way is that you can create a VF page ,add all the content on it and mark it as renderas=pdf.
take this page into blob and attact it to mail.
Thanks
do you need to attach a pdf file in email which is attached on lead or ???
yes.....