s22.imap meeting request code example

Example: s22.imap meeting request

// C#
 
IMail email = new MailBuilder().CreateFromEml(client.GetMessageByUID(uid));
 
foreach (Appointment appointment in email.Appointments)
{
    if (appointment.Method == Method.Request)
    {
        // appointment was created
        string summary = appointment.Event.Summary;
        DateTime? start = appointment.Event.Start;
        DateTime? end = appointment.Event.End;
        string location = appointment.Event.Location;
 
        Console.WriteLine("{0} at {1} ({2}-{3})", summary, location, start, end);
 
        foreach (Participant participant in appointment.Event.Participants)
        {
            Console.WriteLine("Common name: " + participant.Cn);
            Console.WriteLine("Email: " + participant.Email);
            Console.WriteLine("Participation status: " + participant.Status);
        }
    }
    else if (appointment.Method == Method.Cancel)
    {
        // appointment was canceled
        Console.WriteLine("Event was cancelled: " + appointment.Event.UID);
         
    }
    else if (appointment.Method == Method.Reply)
    {
        // someone replied to the request
        foreach (Participant participant in appointment.Event.Participants)
        {
            if (participant.Status == ParticipationStatus.Accepted)
                Console.WriteLine("Event was accepted by: " + participant.Email);
            else if (participant.Status == ParticipationStatus.Declined)
                Console.WriteLine("Event was declined by: " + participant.Email);
        }
 
    }
}

Tags:

Misc Example