You need to sign in to do that
Don't have an account?
Subbu's
need help to send Email with attachment in scheduled class
Hello Everyboby ,
I want to send an email with Messaging.sendEmail method with a pdf attachment ,but the problem is pageReference.getContent() method will not work in the scheduled class . So can anyone have the idea how to acheive this functionality in scheduled class.KIndly share me your ideas about this..
Thanx in Advance.
Hello,
As of now the getContent and getContentAsPDFPageReference methods can not be used in scheduled apex. A work around could be, implement your own webservice with the method that you want to call and calling that webservice from the @future method that is called by the scheduled APEX execute() method.
I would suggest you to vote following idea on idexchange portal:
https://success.salesforce.com/ideaView?id=08730000000ZlnBAAS
@Vinita
Hello ,
thx for your idea sharing .. I tried with the @future annotation ,still it is not working..
Hello,
With @future also getContent will not work, i am suggesting you to create a webservice and make use of getContent in that webservice. Now call that webservice with @future notation in your scheduled apex class.
@Vinita ,
Can you plz provide me sample code , how to use the below statements in webservice callout .
PageReference pg = page.Mypage;
Blob body = pg.getContent();
Hello,
Create a webservice that will be an apex class, like:
global class WebServiceClass {
WebService static String sayHello(String s1){
PageReference pg = page.Mypage;
Blob body = pg.getContent();
return body;
}
}
Now call this in your scheduled apex with @future(callout=ture)
@Vinita ,
Thx for your response .
I tried with your sample code ,but its not working.
The problem is we are receiving an email with attachement but in the attachment there is no content its just coming with minium size 1kb
we planned to acheive this using workflow ..