Eric Wise

Sponsors

The Lounge

Blogs I Read

Fun & Games

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
HowTo: Create an outlook appointment in ASP .NET Part II

What's going on here?  Check my previous post.

 

Here's how to do it without actually creating a file.  Thanks to Bogo for pointing me to the memorystream.

private void Page_Load(object sender, System.EventArgs e)

{

   System.IO.MemoryStream mStream = new System.IO.MemoryStream();

   System.IO.StreamWriter writer = new System.IO.StreamWriter(mStream);

   writer.AutoFlush = true;

   writer.WriteLine("BEGIN:VCALENDAR");

   writer.WriteLine(@"PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN");

   writer.WriteLine("VERSION:1.0");

   writer.WriteLine("BEGIN:VEVENT");

   //Fill in data

   DateTime dueDate;

   dueDate = DateTime.Parse(maintenance.DueDate);

   writer.WriteLine("DTSTART:" + dueDate.Year.ToString() + dueDate.Month.ToString() + dueDate.Day.ToString() + "T170000Z");

   writer.WriteLine("DTEND:" + dueDate.Year.ToString() + dueDate.Month.ToString() + dueDate.Day.ToString() + "T170000Z");

   writer.WriteLine("LOCATION:" + asset.Site.SiteDescription + " - " + asset.Location.LocationDescription + " - " + asset.Room.RoomDescription);

   writer.WriteLine("CATEGORIES:Maintenance");

   writer.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + maintenance.MaintenanceDescription + "=0D=0A");

   writer.WriteLine("SUMMARY:" + asset.Product.ShortDescription + " Maintenance");

   writer.WriteLine("PRIORITY:3");

   writer.WriteLine("END:VEVENT");

   writer.WriteLine("END:VCALENDAR");

   Response.Clear(); // clear the current output content from the buffer

   Response.AppendHeader("Content-Disposition", "attachment; filename=Maintenance.vcs");

   Response.AppendHeader("Content-Length", mStream.Length.ToString());

   Response.ContentType = "application/download";

   Response.BinaryWrite(mStream.ToArray());

   Response.End();

}


Posted 08-26-2004 7:21 PM by Eric Wise

[Advertisement]

Comments

Stefan Cullmann wrote re: HowTo: Create an outlook appointment in ASP .NET Part II
on 08-27-2004 12:16 AM
Hi Eric,
have a look at these greate classes from Ryan Rinaldi:

VCARD: http://blogs.geekdojo.net/ryan/archive/2004/04/28/1797.aspx
VCALENDAR: http://blogs.geekdojo.net/ryan/archive/2004/04/28/1798.aspx

I use them this way:

Integrate a Handler in your web.config
<httpHandlers>
<add verb="*" path="*.vcf" type="xxx.VCard.VcfHandler, xxx" />
httpHandlers>


namespace xxx.VCard
{
public class VcfHandler: IHttpHandler
{
#region IHttpHandler Member
public void ProcessRequest(HttpContext context)
{
VCard vcard = new VCard();
vcard.FirstName="Hans";
vcard.LastName="Testmann";
...
context.Response.ContentType="text/x-vcard";
vcard.Generate(context.Response.OutputStream);
}

public bool IsReusable
{
get { return false;}
}
#endregion

}

I call the vcard like http://myserver/mycards/id1234.vcf

Jason Haley wrote Downloading an event into Outlook
on 08-28-2004 4:58 AM
Downloading an event into Outlook