+ Start a Discussion
Keith Stephens 18Keith Stephens 18 

SalesForce Sendgrid Integration with sendgrid-apex

Hello All,
I am trying to use sendgrid-apex https://github.com/sendgrid/sendgrid-apex to send out vast emails that the Salesforce Email object does not allow.
I have followed there instructions but I am getting an error. SendGridException:[]: Script-thrown exception
The login credz for sendgrid are valid in that we use them in other apps.  And the variables I am using are all string variables.
Also I this code is in a trigger.
System.Debug('before creating sendgrid object');
         SendGrid sendgrid = new SendGrid('username', 'Password');
         SendGrid.email email = new SendGrid.Email();
         email.addTo('me@my.com');
         email.setFrom('me@bar.com');
         email.setSubject(emailSubject + ' ' + candidate);   
         email.setText(plainBody);
        
         System.debug('after send');

         //string response = sendgrid.send(email);
         //SendGrid.SendGridResponse response = sendgrid.send(email);
         //System.Debug('Response= '+response);
         sendgrid.send(email);
I hope someone can help me out.
Thanks,
Keith.
 
Best Answer chosen by Keith Stephens 18
Keith Stephens 18Keith Stephens 18
I resolved my issue. Thanks.