Ecco come creare un nuovo appuntamento per Outlook 2003. Il metodo crea una stringa di informazioni che va salvata in un file con estensione .vcs che successivamente verrà visualizzato dal client di posta Microsoft come un nuovo appuntamento da salvare.

private string AddAppointment(DateTime startDate, DateTime endDate, 

string description, string summary, int priority, string location)
{
StringWriter sw = new StringWriter();
sw.WriteLine("BEGIN: VCALENDAR");
sw.WriteLine("VERSION:1.0");
sw.WriteLine("BEGIN: VEVENT");
sw.WriteLine("DTSTART:{0:yyyyMMdd\\THHmmss\\Z}", startDate.ToUniversalTime());
sw.WriteLine("DTEND:{0:yyyyMMdd\\THHmmss\\Z}", endDate.ToUniversalTime());
sw.WriteLine("LOCATION:{0}", location);
sw.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{0}", description);
sw.WriteLine("SUMMARY;ENCODING=QUOTED-PRINTABLE:{0}", summary);
sw.WriteLine("PRIORITY:{0}", priority);
sw.WriteLine("END:VEVENT");
sw.WriteLine("END:VCALENDAR");
return sw.ToString();
}

Ecco un esempio di utilizzo in una pagina asp.net:

public partial class AddAppointment : System.Web.UI.Page

{
protected void Page_Load(object sender, EventArgs e)
{
string appointment = BuildAppointment();
Response.ContentType = "text/x-vCalendar";
Response.AppendHeader("content-disposition", "inline; filename=nomefile.vcs");
Response.Write(appointment);
Response.End();
}

private string BuildAppointment()
{
return AddAppointment(DateTime.Now, DateTime.Now.AddHours(2), "Note", "Titolo", 1, "Luogo");
}
}