Sending Appointments to a BlackBerry

Sending a calendar appointment over the web is usually straight-forward. Most calendar applications understand the iCalendar format and will automatically import the appointment when an iCalendar file is opened (.ics is the common extension for iCalendar files on the Windows platform). The format of the iCalendar file is fairly simple, here’s an example from the Wikipedia page:

PRODID:-//hacksw/handcal//NONSGML v1.0//EN
SUMMARY:Test Appointment

Normally, attaching an iCalendar file to an email is sufficient, but BlackBerrys are different. BlackBerrys are special. If you try to download an ics file, or open an ics attachment, you’ll see something like this:

Attachment format not recognised

BlackBerry does understand Microsoft Outlook invitations, so the question is how to replicate an Outlook style invitation without using Outlook…

The solution is to embed the iCalendar format directly into the message body, as an alternative “view”. Before running the code below you’ll need to copy the example iCalendar file above into a text file, and rename it “appointment.ics”.

Only two namespaces are required:

using System.IO;
using System.Net.Mail;

These should be changed to point to your local SMTP or Exchange server, the appointment file, and valid email addresses respectively:

private static const string smtpServer = "SmtpServer";
private static const string appointmentPath = @"C:\appointment.ics";
private static const string fromAddress = "";
private static const string toAddress = "";

Note: When the BlackBerry user accepts the invitation, an email acknowledgement is sent back to the sender.

Here’s the code:

using (var client = new SmtpClient(smtpServer))
    var message = new MailMessage();
    message.From = new MailAddress(fromAddress);
    message.To.Add(new MailAddress(toAddress));
    message.Subject = "New Appointment";

    var stream = File.OpenRead(appointmentPath);
    var view = new AlternateView(stream, "text/calendar");


Full credit goes to Philip Bradbear for introducing me to this technique.

This entry was posted in Tips and Tricks and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s