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

FATAL_ERROR|Internal Salesforce.com Error
I wrote a trigger to send email with attachment generated from vfp,
--->trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
SendVFAsAttachment.sendVF('vijaku@xxx.com','Sample Test from Trigger','Sample Email Body',UserInfo.getSessionId());
}
--->public class SendVFAsAttachment{
@future(callout=true)
public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId)
{
//Replace below URL with your Salesforce instance host
String addr = 'https://vsp--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
HttpRequest req = new HttpRequest();
req.setEndpoint( addr );
req.setMethod('POST');
req.setHeader('Authorization', 'OAuth ' + userSessionId);
req.setHeader('Content-Type','application/json');
Map<String,String> postBody = new Map<String,String>();
postBody.put('EmailIdCSV',EmailIdCSV);
postBody.put('Subject',Subject);
postBody.put('body',body);
String reqBody = JSON.serialize(postBody);
req.setBody(reqBody);
Http http = new Http();
HttpResponse response = http.send(req);
}
}
------>@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
@HttpPost
global static void sendEmail(String EmailIdCSV, String Subject, String body) {
List<String> EmailIds = EmailIdCSV.split(',');
PageReference ref = Page.Multi_Topic_PDF;
Blob b = ref.getContentAsPDF();
system.debug('====================10====blob:'+b);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
efa1.setFileName('attachment_WORK.pdf');
efa1.setBody(b);
String addresses;
email.setSubject( Subject +String.valueOf(DateTime.now()));
email.setToAddresses(EmailIds);
email.setPlainTextBody(Body);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
}
--->trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
SendVFAsAttachment.sendVF('vijaku@xxx.com','Sample Test from Trigger','Sample Email Body',UserInfo.getSessionId());
}
--->public class SendVFAsAttachment{
@future(callout=true)
public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId)
{
//Replace below URL with your Salesforce instance host
String addr = 'https://vsp--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
HttpRequest req = new HttpRequest();
req.setEndpoint( addr );
req.setMethod('POST');
req.setHeader('Authorization', 'OAuth ' + userSessionId);
req.setHeader('Content-Type','application/json');
Map<String,String> postBody = new Map<String,String>();
postBody.put('EmailIdCSV',EmailIdCSV);
postBody.put('Subject',Subject);
postBody.put('body',body);
String reqBody = JSON.serialize(postBody);
req.setBody(reqBody);
Http http = new Http();
HttpResponse response = http.send(req);
}
}
------>@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
@HttpPost
global static void sendEmail(String EmailIdCSV, String Subject, String body) {
List<String> EmailIds = EmailIdCSV.split(',');
PageReference ref = Page.Multi_Topic_PDF;
Blob b = ref.getContentAsPDF();
system.debug('====================10====blob:'+b);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
efa1.setFileName('attachment_WORK.pdf');
efa1.setBody(b);
String addresses;
email.setSubject( Subject +String.valueOf(DateTime.now()));
email.setToAddresses(EmailIds);
email.setPlainTextBody(Body);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}
}


Can you share the debug log snippet so we knw what happened before and after this error came up?Also, is this consistent?