Of course. You need to use Appointment.Cancel - it creates an appointment with all events canceled:
Appointment appointment = new Appointment();
Event newEvent = appointment.AddEvent();
newEvent.SetOrganizer(new Person("Alice", "alice@gmail.com"));
newEvent.AddParticipant(new Participant("Bob", "bob@gmail.com"));
newEvent.Description = "description";
newEvent.Summary = "summary";
newEvent.Start = new DateTime(2012, 12, 01, 9, 0, 0);
newEvent.End = new DateTime(2012, 12, 01, 10, 0, 0);
newEvent.Priority = 5;
newEvent.Class = EventClass.Public;
newEvent.AllDay();
Alarm alarm = newEvent.AddAlarm();
alarm.Description = "Reminder";
alarm.BeforeStart(TimeSpan.FromMinutes(5));
string originalUID = e.UID;
int? originalSequence = e.Sequence;
var builder = new MailBuilder();
builder.Subject = "email subject";
builder.To.Add(new MailBox("alice@gmail.com", "Alice"));
builder.From.Add(new MailBox("bob@gmail.com", "Bob"));
builder.Text = "Some text. Appointment is attached";
builder.AddAppointment(appointment);
IMail emailCreate = builder.Create();
using (Smtp client = new Smtp())
{
client.ConnectSSL("imap.gmail.com");
client.UseBestLogin("alice@gmail.com", "pass");
client.SendMessage(emailCreate);
client.Close();
}
Update:
Appointment appointment2 = new Appointment();
Event e2 = appointment2.AddEvent();
e2.SetOrganizer(new Person("Alice", "alice@gmail.com"));
e2.AddParticipant(new Participant("Bob", "bob@gmail.com"));
e2.Description = "description";
e2.Summary = "summary";
e2.Start = new DateTime(2021, 12, 1, 11, 0, 0); // changed
e2.End = new DateTime(2021, 12, 1, 12, 0, 0); // changed
e2.UID = originalUID;
e2.Sequence = originalSequence;
Appointment update = appointment2.Update();
var builder2 = new MailBuilder();
builder2.Subject = "Appointment";
builder2.From.Add(new MailBox("alice@gmail.com"));
builder2.To.Add(new MailBox("bob@gmail.com"));
builder2.AddAppointment(update);
IMail emailCancel = builder2.Create();
using (Smtp client = new Smtp())
{
client.ConnectSSL("imap.gmail.com");
client.UseBestLogin("alice@gmail.com", "pass");
client.SendMessage(emailCancel);
client.Close();
}
Cancel:
Appointment appointment2 = new Appointment();
Event e2 = appointment2.AddEvent();
e2.SetOrganizer(new Person("Alice", "alice@gmail.com"));
e2.AddParticipant(new Participant("Bob", "bob@gmail.com"));
e2.Description = "description";
e2.Summary = "summary";
e2.Start = new DateTime(2021, 12, 5, 9, 0, 0);
e2.End = new DateTime(2021, 12, 5, 10, 0, 0);
e2.UID = originalUID;
e2.Sequence = originalSequence;
Appointment cancel = appointment2.Cancel();
var builder2 = new MailBuilder();
builder2.Subject = "Appointment";
builder2.From.Add(new MailBox("alice@gmail.com"));
builder2.To.Add(new MailBox("bob@gmail.com"));
builder2.AddAppointment(cancel);
IMail emailCancel = builder2.Create();
using (Smtp client = new Smtp())
{
client.ConnectSSL("imap.gmail.com");
client.UseBestLogin("alice@gmail.com", "pass");
client.SendMessage(emailCancel);
client.Close();
}