I have a Visual force page to display certain fields in a certain format. As part of this the page also has a Rich Text Field. There are two buttons on the page, one to send the page as email and the other to download the page as PDF.
When a image is uploaded into the rich text field below is the behavior.
The PDF looks good with the image in it and i was able to download without any issues.
Everything looks good on the email except there is no image on the email from the RTF. It displays a little broken place holder icon rather than a image
I see some similar explanation found in a SFSE thread that is little close to what i need. How do I insert an image from a Rich Text field in an html email template
Is there a workaround for the issue or am I missing something because i was able to download the PDF with the image without any issues ?
Below is relevant code:
VFCODE:
<apex:pageBlock rendered="{!displaydetails}">
<div style='font-size:10pt;font-weight:bold;'>Meeting Details:</div>
<hr width="25%" align="left"></hr>
<!-- details is the apex string for the RTF used here after nullcheck on server -->
<apex:outputText style="font-size:10pt;" value="{!details}" escape="false"/>
<br/>
<br/>
</apex:pageBlock>
APEX METHODS:
// This method is called to send an email
public PageReference sendEmail() {
system.debug('SEND EMAIL PRESSED');
PageReference pdf = Page.SLA_HTMLCallReport;
pdf.getParameters().put('id',(String)model.id);
pdf.setRedirect(true);
Blob b = Blob.valueOf('');
if(!Test.isRunningTest()){
b = pdf.getContent();
}
String[] toAddresses = new List<String>();
for (String item : recipients.split(';') ) {
toAddresses.add(item);
}
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setSubject( subject );
email.setToAddresses( toAddresses );
email.setUseSignature(true);
email.setHtmlBody( body + '<br/><br/>' + b.toString() );
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
emailSent = true;
return null;
}
//This method is called for saving as pdf
public PageReference savePDF() {
PageReference pdf = Page.SLA_PDFCallReport;
pdf.getParameters().put('id',(String)model.id);
return pdf;
}