- Products
- Solutions
- Developers Go to DevelopersDocumentationTools & resources
- Success Stories
- Pricing
- Why Nylas
The Nylas Java SDK is the quickest way to use Java to integrate with 100% of email, calendar, and contacts providers in the world.
import java.util.Arrays; import java.io.IOException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.RequestFailedException; import com.nylas.Draft; import com.nylas.NameEmail; public class SendEmail { public static void main(String[] args) throws IOException, RequestFailedException { // Provide the access token for a specific account String accessToken = "XXX"; // Create client object and connect it to Nylas using // an account's access token NylasClient client = new NylasClient(); NylasAccount account = client.account(accessToken); Draft draft = new Draft(); draft.setSubject("With Love, from Nylas"); draft.setBody("This email was sent using the Nylas Email API. Visit https://nylas.com for details."); draft.setTo(Arrays.asList(new NameEmail("My Nylas Friend", "[email protected]"))); account.drafts().send(draft); } }
import java.util.List; import java.io.IOException; import com.nylas.NylasAccount; import com.nylas.NylasClient; import com.nylas.RequestFailedException; import com.nylas.Calendar; import com.nylas.CalendarQuery; import com.nylas.Event; import com.nylas.EventQuery; public class ReadCalendarsEvents { public static void main(String[] args) throws IOException, RequestFailedException { // Provide the access token for a specific account String accessToken = "XXX"; // Create client object and connect it to Nylas using // an account's access token NylasClient nylas = new NylasClient(); NylasAccount account = nylas.account(accessToken); // Most user account have multiple calendars List<Calendar> calendars = account.calendars().list(); calendars.stream().forEach((Calendar calendar) -> { // Print the name and description for each calendar // and whether or not the calendar is read only. System.out.printf( "Name: %s | Description %s | Read Only: %s\n", calendar.getName(), calendar.getDescription(), calendar.isReadOnly()); }); Calendar calendar = account.calendars().list( new CalendarQuery().limit(1)).get(0); // List the 5 first events from a specified calendar. List<Event> events = account.events().list( new EventQuery().calendarId(calendar.getId()).limit(5)); events.stream().forEach((Event event) -> { System.out.printf( "Title: %s | When %s | Participants: %s\n", event.getTitle(), event.getWhen(), event.getParticipants()); }); } }
Ben is the Developer Advocate for Nylas. He is a triathlete, musician, avid gamer, and loves to seek out the best breakfast tacos in Austin, Texas.