Outlook Appointments, ASP and vCalendar Page 3
Download the authoritative guide: Data Center Guide: Optimizing Your Data Center Strategy
Download the authoritative guide: Cloud Computing: Using the Cloud for Competitive Advantage
vCalendar and ASP
Now comes the fun part ... seeing it work!
Below is posted the text of the ASP page, but due to difficulties with displaying ASP code within an ASP page, I suggest that you download the code and use that copy of the page instead of trying to copy and paste the code below.
The page is mostly self-explanatory for those familiar with ASP. In a nutshell, it draws several input boxes on the screen that collect the information we want in our appointment item: Start, End, Subject, Location and Description. The user is also asked for a directory (on the server) where the file should be created. Of course this wouldn't be done in production, but I included it in the ASP code since it is necessary for the VB Class, and must be provided somewhere. It could be hard-coded and in my example, defaults to "C:\" if the user provides nothing.
The most important part of the code is where the VCSWrap.ApptItem class is instantiated, its properties are set and the CreateVCSEvent method is invoked. The vCalendar file is created and its path is passed to the Response.Redirect method of the ASP page. Since a vcs file cannot be displayed, it is opened automatically. If the user's PIM application is designed to process .vcs files, as Outlook is, an appointment item is opened with all the properties set from our web page.
Dim objVCal, VCalFile Set objVcal = Server.CreateObject("VCalWrap.ApptItem") With objVCal .DTStart = DTStart .DTEnd = DTEnd .Subject = Subject .Location = Location .Description = Description .OutputFilePath = OutputFilePath .TimeZoneBias = -7 .CreateVCSEvent VCalFile = .VCalFile End With Response.Redirect(VCalFile)
ConclusionSome of you may not immediately see the benefits of this technology while others are getting excited and anxious to try out the code. Addmittedly, I was not at first convinced that vCalendar could add value to our web application. Then, our ASP developer put together code similar to the above and did a demo for the sales and marketing guys. Their excitement made up for my lack of it and I decided to give the idea a second look. Although it doesn't solve every problem, it does make it easy to "calendar-enable" your web application ... and it's cool to play with!
********* BEGIN ASP PAGE CODE HERE ************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META content="text/html; charset=unicode" http-equiv=Content-Type><META content="MSHTML 5.00.3207.2500" name=GENERATOR></HEAD><BODY><FORM method=post action="TestVCal.asp" name="VCal"><pre><P align=center><FONT face=Verdana size=4><STRONG>VCalendar Test Page</STRONG></FONT></P><%Dim DTStart, DTEnd, Subject, LocationDim Description, OutputFilePathDim fMissingCriticalData, strMsg, PassDTStart = Request.Form("DTStart")DTEnd = Request.Form("DTEnd")Subject = Request.Form("Subject")Location = Request.Form("Location")Description = Request.Form("Description")OutputFilePath = Request.Form("OutputFilePath")Pass = Request.Form("Pass")fMissingCriticalData=0strMsg = ""' Put some default values in input boxesIf Len(Subject) = 0 Then Subject = "Undetermined"If Len(Location) = 0 Then Location = "Undetermined"If Len(Description) = 0 Then Description = "Undetermined"If Len(OutputFilePath) = 0 Then OutputFilePath ="C:\"If Len(Pass) = 0 Then Pass = 0If Pass > 0 ThenIf Len(DTStart)= 0 OR Not IsDate(DTStart) ThenfMissingCriticalData=1strMsg = strMsg & "<Font color=red>Missing valid start date and time.</Font><BR>"End IfIf Len(DTEnd)= 0 OR Not IsDate(DTEnd) ThenfMissingCriticalData=1strMsg = strMsg & "<Font color=red>Missing valid end date and time.</Font><BR>"End IfElsestrMsg = "<B>Provide the following information to create the appointment item.</b>"End IfIf fMissingCriticalData=1 or pass=0 ThenResponse.Write(strMsg)%><FONT face=Veranda size=3><INPUT id=txtPass name=Pass style="VISIBILITY: hidden" value="<%=Pass + 1 %>"><TABLE Border=0 align=center><tr><td>Start Date and Time:</td><td><INPUT align=right id=txtDTStart name=DTStart value=<%=DTStart %></td><td>(Format: mm/dd/yy hh:nn am/pm)</td></tr><tr><td>End Date and Time:</td><td><INPUT align=right id=txtDTEnd name=DTEnd value=<%=DTEnd %></td><td>(Format: mm/dd/yy hh:nn am/pm)</td></tr><tr><td>Subject:</td><td><INPUT align=right id=txtSubject name=Subject value=<%=Subject %>></td><td></td></tr><tr><td>Location:</td><td><INPUT align=right id=txtLocation name=Location value=<%=Location %>></td><td></td></tr><tr><td>Description:</td><td><INPUT align=right id=txtDescription name=Description value=<%=Description %>></td><td></td></tr><tr><td>Output File Path:</td><td><INPUT align=right id=txtOutputFilePath name=OutputFilePath value=<%=OutputFilePath %>></td><td></td></tr><tr><td></td><td><INPUT id=submit1 name=submit1 type=submit value=Submit></td><td><INPUT id=reset1 name=reset1 type=reset value=Reset></td></tr></FONT></TABLE><%ElseIf Len(Subject) = 0 Then Subject = "(No Subject Given)"If Len(Location) = 0 Then Location = "(No Location Given)"If Len(Description) = 0 Then Description = "(No Description Given)"Dim objVCal, VCalFileSet objVcal = Server.CreateObject("VCalWrap.ApptItem")With objVCal.DTStart = DTStart.DTEnd = DTEnd.Subject = Subject.Location = Location.Description = Description.OutputFilePath = OutputFilePath.TimeZoneBias = -7.CreateVCSEventVCalFile = .VCalFileEnd WithResponse.Redirect(VCalFile)End If%gt</FORM></BODY></HTML>
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...