You need to sign in to do that
Don't have an account?

Not able to send PDF attachment via scheduled apex
Hi There,
I'm trying to send PDF attachment generated from Visualforce page through scheduled apex email class.
I can send PDF attachment using the Email client, but when I am trying to send that automatically using the scheduler PDF attachment is being corrupted
Could you please help me in this.
Thanks.
Vamsi.
here is the alternate method to achieve this.
http://wiki.developerforce.com/index.php/Visualforce_EmailQuote2PDF
All Answers
Can you post your code?
Mike,
File is recognized as PDF but content of it is corrupted. When I try to open the file it says FAIL TO LOAD PDF DOCUMENT.
here is the code
The page Recurring_Invoice I'm calling in this class is working fine, I tested it.
I assume loading individual pages outside the schedule class the PDF displays ok?
It's failing with getContents() part - I would need to try for myself. Can't try now, on the iPad.
Mike,
You bet, Recurring_Invoice visualforce page is rendered as PDF and its displays fine outside the schedule class.
I'll be glad if you can try later and let me know.
Thanks for you time and support.
Vamsi.
This is really interesting, I will try this too.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thank you very much for your interest Ankit. Hope we'll find some solution.
Thanks,
Vamsi.
ok I'm setting this up now
It's in the queue, will execute in 20 mins.
M
mike, any luck? Could you please let me know the result so that we can work togather.
Thanks,
Vamsi.
Failed to load the PDF - same thing, investigating some more
Question - Can force it to run immediately (rather than every hour)
M
Dont know, I'll work on it and let you know I find any.
This maybe a better solution
http://wiki.developerforce.com/index.php/Visualforce_EmailQuote2PDF
Still trying a few things - I think it's a bug
No luck. I would raise a case.
Thanks for your time mike, I've just submitted a case.
Let's see how it goes. I'll keep you informed.
Thanks,
Vamsi.
Hi Mike and Ankit,
As I said I opend a case on this and result is
You can't use the getContent and getContentAsPDFPageReference methods in scheduled Apex.
ref: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm
That is the reason everything is working fine except the attachment. They suggested to post this in ideas exchange so that salesforce will consider in implement it.
Thanks for your time.
Regards,
Vamsi.
Indeed! How can I miss that. This is a limitation.
So post an Idea related to it, explaining a general scenario and post the link here. We all will promote it.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
I would add a flag "To Be Email", then set the flag with schedule which in turn fires individual emails to be sent out??
Or what about using template with visualforce page attached?
Can't believe there is not way to send out invoice PDF's on mass
Guys,
here is the idea link
https://sites.secure.force.com/success/ideaView?c=09a30000000D9xtAAC&id=08730000000ZlnBAAS
Please promote and add you comments explaining further
Mike,
As you suggested I'd try using template with visualforce page attached as explained here http://wiki.developerforce.com/index.php/Visualforce_EmailQuote2PDF
Will let you know.
Hike Mike and Ankit,
I tried tried what explained in above link, it worked fine. Sorry for the late reply.
Thanks,
Vamsi.
here is the alternate method to achieve this.
http://wiki.developerforce.com/index.php/Visualforce_EmailQuote2PDF
Hello.
Is there some way to utilize this method but for a Visualforce PDF that uses a custom controller?
-Greg
I found a solution to sending a Visualforce PDF with a custom controller utilizing an email template and a Visualforce component. Here's the link to the solution thread:
http://boards.developerforce.com/t5/Apex-Code-Development/Sending-email-from-scheduled-apex/m-p/346409
-Greg
Greg,
Thank you for sharing another solution.
-Vamsi.