Working with Calendar Items on Exchange Server using WebDav
Contents
[
Hide
]
Sending Meeting Requests
This article shows how to send a meeting request to multiple recipients using Microsoft Exchange Server and Aspose.Email.
- 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 following code snippet shows you how to send the meeting request are given below.
This file contains 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-.NET | |
try | |
{ | |
string mailboxUri = @"https://ex07sp1/exchange/administrator"; // WebDAV | |
string domain = @"litwareinc.com"; | |
string username = @"administrator"; | |
string password = @"Evaluation1"; | |
NetworkCredential credential = new NetworkCredential(username, password, domain); | |
Console.WriteLine("Connecting to Exchange server....."); | |
// Connect to Exchange Server | |
ExchangeClient client = new ExchangeClient(mailboxUri, credential); // WebDAV | |
// Create the meeting request | |
Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "administrator@" + domain, "bob@" + domain); | |
app.Summary = "meeting request summary"; | |
app.Description = "description"; | |
// Create the message and set the meeting request | |
MailMessage msg = new MailMessage(); | |
msg.From = "administrator@" + domain; | |
msg.To = "bob@" + domain; | |
msg.IsBodyHtml = true; | |
msg.HtmlBody = "<h3>HTML Heading</h3><p>Email Message detail</p>"; | |
msg.Subject = "meeting request"; | |
msg.AddAlternateView(app.RequestApointment(0)); | |
// Send the appointment | |
client.Send(msg); | |
Console.WriteLine("Appointment request sent"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} |