Работа с элементами календаря на Exchange Server с использованием WebDav
Contents
[
Hide
]
Отправка запросов на встречу
В этой статье показано, как отправить запрос на встречу нескольким получателям с использованием Microsoft Exchange Server и Aspose.Email.
- Создайте запрос на встречу с помощью класса Appointment и установите место, время и участников.
- Создайте экземпляр класса MailMessage и установите встречу с помощью метода MailMessage.AddAlternateView().
- Подключитесь к Exchange Server и отправьте запрос на встречу с помощью метода Send(MailMessage).
В этом примере используется класс ExchangeClient, который использует протокол WebDAV для подключения к Exchange Server и может использоваться с любой версией Exchange Server, на которой включен WebDAV, например, Exchange 2000, 2003 или 2007. Следующий фрагмент кода показывает, как отправить запрос на встречу, приведенный ниже.
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); | |
} |