Receive iCalendar meeting request
Mail.dll .NET email component makes receiving iCalendar meeting request fairly easy.
IMail object exposes Appointments collection that contains all appointments that were found while parsing an email.
You can use both IMAP or POP3 protocol to download emails from the server.
Here’s the simple sample showing how to process iCalendar appointments:
// 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); } } }
' VB.NET Dim email As IMail = New MailBuilder().CreateFromEml(client.GetMessageByUID(uid)) For Each appointment As Appointment In email.Appointments If appointment.Method = Method.Request Then ' appointment was created Dim summary As String = appointment.[Event].Summary Dim start As System.Nullable(Of DateTime) = appointment.[Event].Start Dim [end] As System.Nullable(Of DateTime) = appointment.[Event].[End] Dim location As String = appointment.[Event].Location Console.WriteLine("{0} at {1} ({2}-{3})", summary, location, start, [end]) For Each participant As Participant In appointment.[Event].Participants Console.WriteLine("Common name: " + participant.Cn) Console.WriteLine("Email: " + participant.Email) Console.WriteLine("Participation status: " + participant.Status) Next ElseIf appointment.Method = Method.Cancel Then ' appointment was canceled Console.WriteLine("Event was cancelled: " + appointment.[Event].UID) ElseIf appointment.Method = Method.Reply Then ' someone replied to the request For Each participant As Participant In appointment.[Event].Participants If participant.Status = ParticipationStatus.Accepted Then Console.WriteLine("Event was accepted by: " + participant.Email) ElseIf participant.Status = ParticipationStatus.Declined Then Console.WriteLine("Event was declined by: " + participant.Email) End If Next End If Next