0 votes

Appointment that already accepted by user, if that appointment or event get cancel or Update , update or cancel email is not received by recipient.

ev.UID = EventUID           
ev.Sequence = Sequence

appointment.Cancel()
appointment.Event.Cancel()

It gives No error , but even not received any email
if Not accept by user , then it works ( send update or cancel email to recipient),
but only issue if it accepted.
Thanks for your support

by

1 Answer

0 votes

Cancel method creates a canceled event:

Event e = ....
Event canceled = e.Cancel();

You should send this canceled event using Smtp to the recipients that you want to inform about the cancelation.

Remember that you must use the same event's UID and correct sequence number.
For example Gmail also requires all other properties to match.

Appointment appointment = new Appointment();
Event e = appointment.AddEvent();
e.SetOrganizer(new Person("Alice", "alice@example.com"));
e.AddParticipant(new Participant("Bob", "bob@example.com"));
e.Description = "description";
e.Summary = "summary";
e.Start = new DateTime(2021, 12, 5, 9, 0, 0);
e.End = new DateTime(2021, 12, 5, 10, 0, 0);

string originalUID = e.UID;
int? originalSequence = e.Sequence;

var builder = new MailBuilder();
builder.Subject = "Appointment";
builder.From.Add(new MailBox("alice@example.com"));
builder.To.Add(new MailBox("bob@example.com"));
builder.AddAppointment(appointment);
IMail emailCreate = builder.Create();


using (Smtp client = new Smtp())
{
    client.ConnectSSL("imap.example.com");
    client.UseBestLogin("alice@example.com", "password");

    client.SendMessage(emailCreate);

    client.Close();
}

Cancel appointment:

Appointment appointment2 = new Appointment();
Event e2 = appointment2.AddEvent();
e2.SetOrganizer(new Person("Alice", "alice@example.com"));
e2.AddParticipant(new Participant("Bob", "bob@example.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@example.com"));
builder2.To.Add(new MailBox("bob@example.com"));
builder2.AddAppointment(cancel);
IMail emailCancel = builder2.Create();

using (Smtp client = new Smtp())
{
    client.ConnectSSL("imap.example.com");
    client.UseBestLogin("alice@example.com", "password");

    client.SendMessage(emailCancel);

    client.Close();
}
by (297k points)
...