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
pfeppfep 

Demonstrate emailing a VisualForce page (no standardController) via schedule

is this possible? if yes how? any ideas

colemabcolemab

I think you need a scheduable apex class and in the class you can use getcontent or getcontentaspdf to generate the attachment and send the email message.

 

Then you would use anonymous apex to schedule the class.

pfeppfep

someone had confirm that getContentAsPDF() isn’t supported for scheduled Apex. I think the same applies to getContent().

 

http://forums.sforce.com/t5/Visualforce-Development/Visualforce-within-Scheduled-Apex/td-p/174977

pfeppfep

here we had VF page that need to be emailed and It use live datas. when sending that page they should be able to see live datas so its a problem?

colemabcolemab

If you don't need it in PDF format, could you just add the VF page to a dashboard and then set the dashboard up to email on a schedule?

 

Sorry, I didn't realize that scheduled apex didn't support getcontent.  

 

Another option maybe using the scheduled apex to call an @Future(Callout=true) method.  Then in that @Future(Callout=true) method, call out to the salesforce webservice and get the body then create an email attachment from the body and send an email with that file.  The down side here is that the file would be in HTML and not PDF format and some coding must take place.

 

 

colemabcolemab

I am not sure what you are asking about live data but any thing emailed (dashboard, html, pdf) will be a snapshot of the data at the time it was sent.    This is because re-pulling the data from the system anytime the document is opened would require some kind of session / authentication with sales force and thus would require alot more effort but you might be able to do it in an HTML page w/ AJAX or just JS.

pfeppfep

ok i like the idea..adding VF page to dashboard and email it as schedule but how?

u gootta guide me on it..

colemabcolemab

First off, mock up your VF page.  It doesn't have to be all of the logic you need just yet but just a basic mock up.

 

Once you have created this, goto your reports tab and create a new dashboard.  Once you are on the dashboard, look under the components tab for the "VF" icon, it should be the last one.  Drag it over to a column and set that column to "Wide" then remove the other columns that you can remove (i think you will have to have 2 columns).  Set the other column to narrow.

 

The width / height may be your issue with doing this via dashboard - you may have to make this "wide" but not full page and make up for it by making it tall.

 

Next goto the data sources tab (next to components tab) and find your VF page.   Drag and drop this page on your VF icon. 

 

Save your dashboard and run it to preview it.   Once it looks good, you can schedule a dashboard refresh and set who gets emailed the dashboard and when.

pfeppfep

Thanks i will try.