try{
Console.WriteLine(“Trying to send an email with meeting request…”);
SmtpClient client =
new SmtpClient(host, port, username, password);
if (isSSL ==
true)
{
client.Port = portSSL;
client.EnableSsl =
true;
client.SecurityMode = SmtpSslSecurityMode.Explicit;
}
MailMessage message =
new MailMessage(sender, recipient, “05 - test email - single meeting request”, “test email”);
// create the meeting request Appointment app =
new Appointment(“meeting request”, DateTime.Now.AddHours(1),
DateTime.Now.AddHours(1.5), sender, recipient);
app.Summary = “meeting request summary”;
app.Description = “description”;
message.AddAlternateView(app.RequestApointment());
client.Send(message);
Console.WriteLine(“Meeting request sent. Please check Inbox. Next step
is to Update
this appointment.”);
// update appointment - time one hour later Appointment appUpdate =
new Appointment(“meeting request”, DateTime.Now.AddHours(1),
DateTime.Now.AddHours(1.5), sender, recipient);
appUpdate.UniqueId = app.UniqueId;
appUpdate.StartDate = app.StartDate.AddHours(1);
appUpdate.EndDate = app.StartDate.AddHours(1);
appUpdate.Location = “update meeting request”;
appUpdate.Summary = “update meeting request summary”;
appUpdate.Description = “update”;
MailMessage msgUpdate =
new MailMessage(sender, recipient, “06 - test email - update meeting request”, “test email”);
msgUpdate.AddAlternateView(appUpdate.UpdateAppointment());
client.Send(msgUpdate);
Console.WriteLine(“Update request sent. Please check Inbox. The appointment should be updated
in Calendar. Next step
is to cancel
this appointment.”);
// cancel appointment Appointment appCancel =
new Appointment(“meeting request”, DateTime.Now.AddHours(1),
DateTime.Now.AddHours(1.5), sender, recipient);
appCancel.UniqueId = app.UniqueId;
appCancel.Location = “cancel meeting request”;
appCancel.Summary = “cancel meeting request summary”;
appCancel.Description = “cancel”;
MailMessage msgCancel =
new MailMessage(sender, recipient, “07 - test email - cancel meeting request”, “test email”);
msgCancel.AddAlternateView(appCancel.CancelAppointment());
client.Send(msgCancel);
Console.WriteLine(“Cancel request sent. Please check Inbox. A cancel meeting request should be present
in Inbox.”);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}