function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul Sangwan7341Rahul Sangwan7341 

Parse PDF to String

//Code of webservice class to set file as attachment
            for (String att: attachmentMap.keySet()) {
                String content = attachmentMap.get(att).toString();
                body += '&files[' + att + ']=' + EncodingUtil.urlEncode(content, 'UTF-8');
            }


//
Document doc = [Select Id, Name, body from Document where id='0159000000Bq3oI'];
List<String> toEmail = new List<String>();
List<String> ccEmail = new List<String>();
List<String> bccEmail = new List<String>();
toEmail.add('test@gmail.com , test To Name');


String fromEmail = test1@gmail.com';
String subject = 'test subject';
String bodyText = 'test body';
String bodyHtml = '<h1>test body</h1><br/>tested';
String fromName = 'Sangwan';
String replyto  = '';   
String extheaders = null;
Map<String,Blob> attachmentMap = new Map<String,Blob>();
//Blob att = doc.body;
attachmentMap.put(doc.Name, doc.body);
SendGripApiClass.sendEmail(toEmail, ccEmail, bccEmail, fromEmail, subject, bodyText, bodyHtml, fromName,
                          replyto, extheaders, attachmentMap);
Hi I have written code for integration with sendgrid.
Now when i am sending a text or CSV file it is working fine but if i am sending PDF,JPEG,Word file it is showing error while i am setting attachment in URL parameter only.
ShashankShashank (Salesforce Developers) 
Would you be able to provide the error message you are seeing?