Skip to contentSkip to navigationSkip to topbar
On this page

v3 API Kotlin Code Example


(information)

Info

We recommend using SendGrid Java, our client library, available on GitHub(link takes you to an external page), with full documentation.

(information)

Info

Do you have an API Key(link takes you to an external page) yet? If not, go get one. You're going to need it to integrate!


Using SendGrid's Java Library

using-sendgrids-java-library page anchor
1
// using SendGrid's Java Library
2
// https://github.com/sendgrid/sendgrid-java
3
import com.sendgrid.*;
4
import java.io.IOException;
5
6
class Example {
7
private fun sendEmail() {
8
9
val sendgrid = SendGrid("SENDGRID_APIKEY")
10
val email = SendGrid.Email()
11
12
email.addTo("test@sendgrid.com")
13
email.setFrom("you@youremail.com")
14
email.setSubject("Sending with SendGrid is Fun")
15
email.setHtml("and easy to do anywhere, even with Kotlin")
16
17
val response = sendgrid.send(email)
18
}
19
}