I'm trying to create a csv file attached to a visualforce email template. The csv file is based on a report that has a bunch of columns (fields) already, and all that I usually do is pass the Quote ID and the report fills in the line items.
I've tried the below and it generates the report in a CSV but with no data.
Visualforce Email Template Attachment
<messaging:attachment filename="{!relatedTo.Name}-{!relatedTo.EmailPDFName__c}.csv" >
<c:QuoteCSV xtheQuoteID="{!relatedTo.Id}" />
</messaging:attachment>
Visualforce Component
<apex:attribute name="xtheQuoteID" description="quote ID" type="String" assignTo="{!theQuoteID}"/>
<apex:outputText value="{!CSVStream}" escape="false"/>
</apex:component>
Apex Controller NOTE: I tried to re-engineer from another process
public class QuoteLineEmailController {
public static Boolean isTest;
public static String strOut = '';
public String theQuoteID{get;set;}
public void CSVStream () {
strOut = '';
}
public String getCSVStream() {
executeRpt();
return strOut;
}
public void executeRpt() {
String requestURL;
requestURL = '/00OF0000005ueLL?xf=localecvs&export=&pv0=' + theQuoteID + '?csv=1&exp=1';
strOut = Test.isRunningTest() ? 'test' : new PageReference(requestURL).getContent().toString();
System.debug('CALLING executeRpt: output= ' + strOut );
}
}