+1 vote

I want the way to accept and reject the calendar send by another user. can you please help me with that?

by (1.6k points)

1 Answer

+1 vote

Meeting requests/responses are send/received as email attachments.

As this topic is quite broad and complex, consider familiarizing yourself with iCalendar spec.

Mail.dll can send emails with iCalendar appointments, receive them and parse them:

https://www.limilabs.com/blog/send-icalendar-meeting-requests

https://www.limilabs.com/blog/receive-icalendar-meeting-request

This is the code for attendee, that accepts received appointment:

string attendee = "attendee@example.com";
string attendeePassword = "xxxx";

// First you need to receive the invite:
Appointment invite;

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.example.com");
    imap.UseBestLogin(attendee, attendeePassword);

    imap.SelectInbox();

    byte[] eml = imap.GetMessageByUID(imap.Search(Flag.Unseen)[0]);
    IMail mail = new MailBuilder().CreateFromEml(eml);

    invite = mail.Appointments[0];

    imap.Close();
}

Accept the invite:

Appointment accepted = invite.Accept(attendee);

Send it back:

string organizer = "organizer@other.com"; // should be extracted from the invite 
// for example: accepted.Event.Organizer.Email

using (Smtp smtp = new Smtp())
{
    smtp.ConnectSSL("smtp.example.com");
    smtp.UseBestLogin(attendee, attendeePassword);

    MailBuilder mailBuilder = new MailBuilder();
    mailBuilder.From.Add(new MailBox(attendee));
    mailBuilder.To.Add(new MailBox(organizer));

    mailBuilder.AddAppointment(accepted);

    smtp.SendMessage(mailBuilder.Create());

    smtp.Close();
}
by (297k points)
for send it back can't we use the reply method instead of new mail sent.
You can use IMail.Reply to create MailBuilder however you also need to Accept/Reject the Appointment and attach it using AddAppointment method.
...