You need to sign in to do that
Don't have an account?
Ab
Hello,
I am trying to send a pdf version of webpage to an email address.
but i always receive a blank page as attachment.
How can i resolve it.
It is not necessary for me to send email but i just want to attach it as attachment somewhere and i should see as Pdf.
thanks for suggestion
covert webpage to pdf and attach as attachment to email or an account or anything
Hello,
I am trying to send a pdf version of webpage to an email address.
but i always receive a blank page as attachment.
How can i resolve it.
<apex:page docType="html-5.0" showHeader="false" controller="TestWebPageToPdfToDelete" sidebar="false"> <apex:form> <apex:commandButton action="{!SendThisEmail}" value="send" /> <apex:iframe src="https://google.com" scrolling="true"/> </apex:form> </apex:page>
public class TestWebPageToPdfToDelete { public void SendThisEmail() { List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); attach.setContentType('application/pdf'); attach.setFileName('Report.pdf'); pagereference Pg = Page.TestWebPageToPdfToDelete; Blob body = pg.getcontentAsPdf(); System.debug('$$'+body.size()); System.debug('$$'+body); attach.Body = body; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(new String[] { 'test@gmail.com' }); mail.setSubject('PDF Generation'); mail.setHtmlBody('PFA'); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); mails.add(mail); if(!mails.isEmpty()) { Messaging.SendEmail(mails); } } }
It is not necessary for me to send email but i just want to attach it as attachment somewhere and i should see as Pdf.
thanks for suggestion
May I request you to please refer the below link for reference.
- http://salesforce.stackexchange.com/questions/89725/how-to-attach-pdf-files-into-an-email
I hope it will be helpful.BestRegards
RahulKumar