function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
samita das 7samita das 7 

Sending vf page records as excel in mail attachement and schedule

Hi,
I have built a vf page that contains some dynamic columns . I want to send this report in mail but in excel format . This mail will be scheduled weekly. 
I have refered certain blogs but then , the records are queried from database and then it is send. I want the vf page itself as it is but in excel format to be send as an attachment in mail. Please help!!
 
Raj VakatiRaj Vakati
You can put your visualforce page inside a visualforce email template like:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_attachments.htm

You can change the render type for the attachments just like in your visualforce page like this example for PDF:

 
<messaging:attachment renderAs="text/csv" filename="cases.csv">
	<html>
		<body>
		<p>You can display your {!relatedTo.name} cases as a PDF:</p>
			<table border="0" >
			<tr>
				<th>Case Number</th><th>Origin</th>
				<th>Creator Email</th><th>Status</th>
			</tr>
			<apex:repeat var="cx" value="{!relatedTo.Cases}">
			<tr>
				<td><a href = 
					"https://na1.salesforce.com/{!cx.id}">{!cx.CaseNumber}
				</a></td>
				<td>{!cx.Origin}</td>
				<td>{!cx.Contact.email}</td>
				<td>{!cx.Status}</td>
			</tr>
			</apex:repeat> 
		</table>
		</body>
	</html>
</messaging:attachment>

 
Raj VakatiRaj Vakati
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_attachments.htm
samita das 7samita das 7
Hi Raj ,

But then how will be Iable to schedule it ??