Aspose.Email  for .java

Send Email via Exchange Web Service in Java

A progressive solution to implement email sending capability into Java projects.

  Download Free Trial
Email communication is one of the motive forces of modern businesses. It may be challenging to design an application that would satisfy the company’s needs but not for those using the right tools. When it comes to building robust and effective apps, Aspose.Email for Java becomes a practical solution. It is a formidable and versatile library designed to simplify email processing tasks. Its rich set of tools and features will revolutionize your email-handling capabilities including seamless message sending and take your Java applications to new heights.

How to Send a Message via EWS using the Java API

The following code sample will guide you through the process of message sending using the Java library, making it easier than ever to integrate email functionality into your applications. In a few lines of code, you will establish a connection to the EWS server, create a new message and send it being sure of its delivery or you will get a clear error handling support if any.


// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.getEWSClient("", "username", "password", "domain");

// Create instance of type MailMessage
MailMessage msg = new MailMessage();
msg.setTo(MailAddressCollection.to_MailAddressCollection("recipient@ "));
msg.setSubject("Sending message from exchange server");
msg.setHtmlBody("<h3>sending message from exchange server</h3>");

try {
// Send the message
 System.out.println("Email sent successfully.");
        } catch (Exception e) {

Utility Features

Apart from the reliability and simplicity of its use, the library provides you with the following capabilities in the work with the EWS Client:

  • Reading mailbox files and filtering.

  • Managing conversation and calendar items.

  • Working with contacts, distribution lists, tasks, appointments etc.

  • Support for TLS and AutodiscoverService.

  • Getting messages from a shared mailbox and more.

About the Java API in Short

In this article we’ve introduced Aspose.Email for Java, a trusted companion for making email communication effortless and efficient. From sending and receiving emails to advanced email processing and automation, these capabilities make it a versatile and comprehensive library. Don’t miss the opportunity to streamline your email-related processes and elevate your Java applications.

Alternative Methods for Sending Emails