Sending Meeting Requests with Exchange Server using WebDav
Contents
[
Hide
]
This article shows how to send a meeting request to multiple recipients using Microsoft Exchange Server and Aspose.Email. It also explains how to adjust the code to work with Exchange Web Services.
Send Meeting Requests using Web Dav
To send a meeting request:
- Create a meeting request using the Appointment class and set the location, time and attendees.
- Create an instance of the MailMessage class and set the appointment using the MailMessage.addAlternateView() method.
- Connect to the Exchange Server and send the meeting request using the send(MailMessage) method.
This example uses the ExchangeClient class, which uses the WebDAV protocol to connect to the Exchange Server and can be used with any version of Exchange Server on which WebDAV is enabled, for example, Exchange 2000, 2003 or 2007.
The code snippets used to send the meeting request are given below:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java | |
try { | |
String domain = "litwareinc.com"; | |
ExchangeClient client = new ExchangeClient("http://MachineName/exchange/Username", "username", "password", "domain"); | |
// Create the meeting request | |
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); | |
Date startDate = sdf.parse("10/05/2015 10:00:00"); | |
Date endDate = sdf.parse("10/05/2015 10:30:00"); | |
MailAddressCollection coll = new MailAddressCollection(); | |
coll.add("bob@" + domain); | |
Appointment app = new Appointment("meeting request", startDate, endDate, new MailAddress("administrator@" + domain), coll); | |
app.setSummary("meeting request summary"); | |
app.setDescription("description"); | |
// Create the message and set the meeting request | |
MailMessage msg = new MailMessage(); | |
msg.setFrom(new MailAddress("administrator@" + domain)); | |
msg.setTo(coll); | |
msg.isBodyHtml(true); | |
msg.setHtmlBody("<h3>HTML Heading</h3><p>Email Message detail</p>"); | |
msg.setSubject("meeting request"); | |
msg.addAlternateView(app.requestApointment(0)); | |
// Send the appointment | |
client.send(msg); | |
System.out.println("Appointment request sent"); | |
} catch (ExchangeException ex) { | |
System.out.println(ex.getMessage()); | |
} |