You need to sign in to do that
Don't have an account?
amrit
How to send pdf as email attachment which is generated from visual force page?
Hi,
I want to send pdf as email attachment which is generated from visualforce page .I created a button called EmailReceipt .When i click that button it will automatically attach that pdf document and send to that person's mailid which we are capturing from account.How is it possible?
Thanks
Hi,
Please Refer below code,
public static void send(id cpr) {
// Define the email
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
PageReference pdf = Page.cprpdf;
pdf.getParameters().put('id','a0CQ0000002Ihjj');
pdf.setRedirect(true);
Blob b = pdf.getContent();
// Create the email attachment
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('attachment.pdf');
efa.setBody(b);
String addresses;
email.setSubject( 'subject' );
string[] test = new String[] {'aa@aa.com'};
email.setToAddresses( test );
email.setPlainTextBody(' body' );
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
// Send it
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
Thanks,
Ahmed
Hi
Thanks for your reply.In your code which Id ie id cpr is passing as a parameter in send method.Is it that cprpdf Id.
i am having similar requirment ,i wan send each image chart as email attahcment .i am having one vf with multiple chart.please guide asap.