You need to sign in to do that
Don't have an account?
SFDC coder
Page is not rendered in pdf format,although specified
This my code that sends an email with an attachment.The attachment is supposed to be a file in pdf format.
Error is: email is sent properly with an attachment,but the attachment is not in the pdf format
Waiting for reply...
Error is: email is sent properly with an attachment,but the attachment is not in the pdf format
//Method that sends the pdf as attachment to the customer public PageReference sendEmailWithAttachment() { System.debug('**** curr id is'+currentId); //Getting the page to be rendered as pdf PageReference pdfPage=new PageReference('/apex/PropertyDetailPage?id='+currentId); //pdf.getParameters().put('id',); body=pdfPage.getContentAsPdf(); //creating the email attachment Messaging.EmailFileAttachment attach=new Messaging.EmailFileAttachment(); attach.setContentType('application/pdf'); attach.setFileName('Property Details'); attach.setBody(body); attach.setInline(false); //code to send the mail to the specified address Messaging.SingleEmailMessage email=new Messaging.SingleEmailMessage(); String []toaddr=new String[]{cemail}; email.setToAddresses(toaddr); email.setSubject('Acme Property Details'); email.setHtmlBody('Here is the email you requested! Check the attachment!'); email.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email }); return null; }
Waiting for reply...
PageReference pdf = Page.attachmentPDF;
pdf.getParameters().put('id',(String)account.id);
pdf.setRedirect(true);
All Answers
<apex:page controller="DetailPageExt" >
<apex:form >
<apex:detail subject="{!recordid}" relatedList="false" inlineEdit="false" relatedListHover="false"/>
</apex:form>
</apex:page>
Is there any problem with the markups used?
Thanks in advance
Thanks for the reply....
The problem is that i cant add render as attribute as the page would then get displayed to the user in a pdf file format
you said ur getting the mail have u got the attachment with the mail if yes in which format ur getting the attachment..
just give ur file name in class code with a .pdf extension i.e Property details.pdf and try...
thanks,
pradeep.
yes i am receiving the email and the format is of type windows file....Is there any problem with using the apex:define tag in my vf page?......coz i read somewhere that its an usafe component to be used while generating pdf
PageReference pdf = Page.attachmentPDF;
pdf.getParameters().put('id',(String)account.id);
pdf.setRedirect(true);
Also theres a field on my detail page wich is a formula field and it displays an image..but in the pdf the image is not displayed properly..is it that we can't display images in pdf's created from apex?
you cant restrict the data on detailpage while rendering if u want to do so just create a vf page for ur detail page and display what ever fields u want and render it to pdf.
Thanks a lot For your help