Send iCalendar meeting requests

Mail.dll .NET email component includes support for popular iCalendar standard.

iCalendar is used by most popular email clients like Outlook or Gmail. It allows Internet users to send meeting requests and tasks to other users, via email, or sharing files with an extension of .ics.

Recipients of the iCalendar data file (with supporting software, such as an email client or calendar application) can respond to the sender easily or counter propose another meeting date/time.

First make sure that your ‘usings’ or ‘Imports’ section includes all needed namespaces:

// C#

using Limilabs.Mail;
using Limilabs.Mail.Fluent;
using Limilabs.Mail.Appointments;
' VB.NET

Imports Limilabs.Mail
Imports Limilabs.Mail.Fluent
Imports Limilabs.Mail.Appointments

And now the code.

First we’ll create an appointment object add new event to it:

Appointment appointment = new Appointment();
Event e = appointment.AddEvent();

Then we need to set start and end dates:

e.Description = "Status meeting description";
e.Summary = "Status meeting summary";
e.Start = new DateTime(2015, 05, 10, 16, 00, 00);
e.End = new DateTime(2015, 05, 10, 17, 00, 00);

Now we’ll add all required and optional participants to it:

e.SetOrganizer(new Person("Alice", "alice@mail.com"));

e.AddParticipant(new Participant(
	"Bob", "bob@mail.com", ParticipationRole.Required, true));
e.AddParticipant(new Participant(
	"Tom", "tom@mail.com", ParticipationRole.Optional, true));
e.AddParticipant(new Participant(
	"Alice", "alice@mail.com", ParticipationRole.Required, true));

We’ll add an alarm to the event (set 15 minutes before the event start):

Alarm alarm = e.AddAlarm();
alarm.BeforeStart(TimeSpan.FromMinutes(15));

Finally we’ll create an email add the appointment to it and send it:

Mail.Text("Status meeting at 4PM.")
	.Subject("Status meeting")
	.From("alice@mail.com")
    .To("bob@mail.com")
    .AddAppointment(appointment)
    .UsingNewSmtp()
    .WithCredentials("alice@mail.com", "password")
	.Server("smtp.mail.com")
	.WithSSL()
	.Send();

The entire C# code looks as follows:

Appointment appointment = new Appointment();

Event e = appointment.AddEvent();
e.Description = "Status meeting description";
e.Summary = "Status meeting summary";
e.Start = new DateTime(2015, 05, 10, 16, 00, 00);
e.End = new DateTime(2015, 05, 10, 17, 00, 00);

e.SetOrganizer(new Person("Alice", "alice@mail.com"));

e.AddParticipant(new Participant(
	"Bob", "bob@mail.com", ParticipationRole.Required, true));
e.AddParticipant(new Participant(
	"Tom", "tom@mail.com", ParticipationRole.Optional, true));
e.AddParticipant(new Participant(
	"Alice", "alice@mail.com", ParticipationRole.Required, true));

Alarm alarm = e.AddAlarm();
alarm.BeforeStart(TimeSpan.FromMinutes(15));

Mail.Text("Status meeting at 4PM.")
	.Subject("Status meeting")
	.From("alice@mail.com")
    .To("bob@mail.com")
    .AddAppointment(appointment)
    .UsingNewSmtp()
    .WithCredentials("alice@mail.com", "password")
	.Server("smtp.mail.com")
	.WithSSL()
	.Send();

…and the VB.NET version:

Dim appointment As New Appointment()

Dim e As [Event] = appointment.AddEvent()
e.Description = "Status meeting description"
e.Summary = "Status meeting summary"
e.Start = New DateTime(2015, 5, 10, 16, 0, 0)
e.[End] = New DateTime(2015, 5, 10, 17, 0, 0)

e.SetOrganizer(New Person("Alice", "alice@mail.com"))

e.AddParticipant(New Participant( _
	"Bob", "bob@mail.com", ParticipationRole.Required, True))
e.AddParticipant(New Participant( _
	"Tom", "tom@mail.com", ParticipationRole.[Optional], True))
e.AddParticipant(New Participant( _
	"Alice", "alice@mail.com", ParticipationRole.Required, True))

Dim alarm As Alarm = e.AddAlarm()
alarm.BeforeStart(TimeSpan.FromMinutes(15))

Mail.Text("Status meeting at 4PM.") _
	.Subject("Status meeting") _
	.From("alice@mail.com") _
	.[To]("bob@mail.com") _
	.AddAppointment(appointment) _
	.UsingNewSmtp() _
	.WithCredentials("alice@mail.com", "password") _
	.Server("smtp.mail.com") _
	.WithSSL() _
	.Send()

You can download Mail.dll .NET email component here.

Tags: , , , ,

Questions?

Consider using our Q&A forum for asking any questions.