A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://sendgrid.com/docs/Integrate/Code_Examples/java.html below:

v3 API Java Code Example | SendGrid Docs

1

// using SendGrid's Java Library

2

// https://github.com/sendgrid/sendgrid-java

4

import com.sendgrid.helpers.mail.*;

5

import com.sendgrid.helpers.mail.objects.*;

6

import java.io.IOException;

9

public static void main(String[] args) throws IOException {

10

Email from = new Email("test@example.com");

11

String subject = "Sending with SendGrid is Fun";

12

Email to = new Email("test@example.com");

13

Content content = new Content("text/plain", "and easy to do anywhere, even with Java");

14

Mail mail = new Mail(from, subject, to, content);

16

SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));

17

Request request = new Request();

19

request.setMethod(Method.POST);

20

request.setEndpoint("mail/send");

21

request.setBody(mail.build());

22

Response response = sg.api(request);

23

System.out.println(response.getStatusCode());

24

System.out.println(response.getBody());

25

System.out.println(response.getHeaders());

26

} catch (IOException ex) {


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4