We recommend using SendGrid Java, our client library, available on GitHub, with full documentation.
The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see Continue Using V2 in Java.
_18// using SendGrid's Java Library_18// https://github.com/sendgrid/sendgrid-java_18import com.sendgrid.*;_18_18public class SendGridExample {_18 public static void main(String[] args) {_18 SendGrid sendgrid = new SendGrid("SENDGRID_APIKEY");_18_18 SendGrid.Email email = new SendGrid.Email();_18_18 email.addTo("test@sendgrid.com");_18 email.setFrom("you@youremail.com");_18 email.setSubject("Sending with SendGrid is Fun");_18 email.setHtml("and easy to do anywhere, even with Java");_18_18 SendGrid.Response response = sendgrid.send(email);_18 }_18}