• Aman Verma 45
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I've written Code for sending Reports as email. It Contains future method as well as a Scheduler.
I've written a test class for the same. 
It is giving this error "Methods defined as TestMethod do not support getContent call".
P.S. I am new to Salesforce.
global class Exporter2 implements Schedulable {
    
    public void execute(SchedulableContext sc){
        sendMail();
    }
    @future(callout=true)
    public static void sendMail()
    {
        ApexPages.PageReference report = new ApexPages.PageReference('/00O6F0azs00BTlGa?csv=1');
        Messaging.EmailFileAttachment attachment = new Messaging.EmailFileAttachment();
        attachment.setFileName('report.csv');
        attachment.setBody(report.getContent());
        attachment.setContentType('text/csv');
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setFileAttachments(new Messaging.EmailFileAttachment[] { attachment } );
        message.setSubject('Report');
        message.setPlainTextBody('The report is attached.');
        message.setToAddresses( new String[] {'xyz@zbc.com'} );
        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } );
        
    }
}

Here is my Test Class.
@IsTest
public class Exporter2Test {
    
    @IsTest static void  testschedule() {

        Test.StartTest();
        Exporter2 exp = new Exporter2();
        String sch = '0 05 11 * * ?';
        system.schedule('Report test',sch,exp);
        Test.stopTest();
    }
}



 
When we pass an object by firing events between components , whether they are passed by value or by reference?

Hello,

 

I am trying to execute a Http Callout to a webservice that is with windows machine and the credentials were given to me as domain\username

password

 

I wrote a simple http callout as mentioned in the docs. Did the base 64 thing for username:pwd but I keep getting

HttpResponse[Status=Unauthorized, StatusCode=401]

 

I tried to put domain as domain\username, domain:username:password with other combinations of moving domain first and last but nothing seems to work.

 

I have my authorizationheader set as follows

 

    Blob headerValue = Blob.valueOf(username + ':' + password);
    String authorizationHeader = 'NTLM ' +   EncodingUtil.base64Encode(headerValue);

 

I tried BASIC above and then tried NTLM too but with same result.

 

Any help is greatly appreciated.

 

Thanks

  • February 23, 2011
  • Like
  • 0