Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global class CallSubscriptionReportScheduler {
- @future(callout=true)
- public static void SentSubscriptionData()
- {
- Id userdetail=[Select id from user where email='xyz@gmail.com'].id;
- OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'info@xyz.com' Limit 1];
- ApexPages.PageReference report = new ApexPages.PageReference('/00O6F00000CGpHH?csv=1');
- Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
- attachment.setFileName('Data_Report.csv');
- attachment.setBody(report.getContent());
- attachment.setContentType('text/csv');
- Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
- message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
- message.setSubject('Data');
- message.setPlainTextBody('The report is attached.');
- message.setOrgWideEmailAddressId(owea.get(0).Id);
- message.setReplyTo('sfdcadmin@xyz.com');
- message.setTargetObjectId(userdetail);
- message.setSaveAsActivity(false);
- Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
- }
- }
- @isTest
- public class TestWeeklySubscriptionData {
- public static String CRON_EXP = '0 0 1 ? * MON';
- static testmethod void testsubscription() {
- Test.startTest();
- WeeklySubscriptionData uca = new WeeklySubscriptionData();
- String jobId = System.schedule('ScheduledApexTest',CRON_EXP,new WeeklySubscriptionData());
- Test.stopTest();
- // after the testing stops, assert records were updated properly
- //System.assertEquals(6, [select count() from Lead where Lead_Type__c='Insurance' AND RecordTypeId ='0126F0000016MZP']);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement