Tag Archive for perl

Calendar request web form for MS Outlook

For a while, we have used the moderated folder and custom form features of Microsoft Outlook and Microsoft Exchange to allow users to request school vehicles for trips and other purposes. It didn’t work well. Our users view this public folder calendar through Outlook, Entourage, and Outlook Web Access. Only Outlook supports custom forms. Public folders were difficult to find. They don’t sync well with Entourage. It was a mess.

With our upgrade to Exchange 2007, we decided to move away from public folders and create buses as resources instead. At the same time, we wanted to build an easier-to-use request form for users. We wondered whether we could build a simple web script (in Perl or PHP) and send Outlook a calendar object that it could use.

It worked! Uncharacteristically, Microsoft uses an open, standard format for calendar entries. Below, I have reproduced part of a script I wrote that sends a .vcs (vcalendar) file as an attachment that our transportation coordinator may open in Outlook, review, and add to a calendar. May other potential uses for this exist.

Please do try this code and let me know any improvements you make. This is only part of our script code. It won’t work on your server as is!


use Time::Local;
use CGI qw(:standard);
use Net::SMTP;

sub write_form {

param(-name=>'action', -value=>'save_form');

$output = start_form .
p . "Please complete the following form to request a school vehicle." .
"<div style=\"border:1px solid black; padding:5px; margin:20px 0 20px 0;\"><b>Required Information</b>" .
p . "Activity: " . textfield(-name=>'activity', -size=>60) .
p . "Destination: " . textfield(-name=>'destination', -size=>60) .
p . "Depart date: " . popup_menu(-name=>'depart_month', -values=>['',@months], -labels=>\%month_labels) . ' ' . popup_menu(-name=>'depart_day', -values=>['',@mdays]) . ' ' . popup_menu(-name=>'depart_year', -values=>['',@years], -default=>$year) . ' Hour: ' . popup_menu(-name=>'depart_hour', -values=>['',@hours], -labels=>\%hours_labels) . ' Min: ' . popup_menu(-name=>'depart_min', -values=>['',@mins]) .
p . "Return date: " . popup_menu(-name=>'return_month', -values=>['', @months], -labels=>\%month_labels) . ' ' . popup_menu(-name=>'return_day', -values=>['',@mdays]) . ' ' . popup_menu(-name=>'return_year', -values=>['',@years], -default=>$year) . ' Hour: ' . popup_menu(-name=>'return_hour', -values=>['',@hours], -labels=>\%hours_labels) . ' Min: ' . popup_menu(-name=>'return_min', -values=>['',@mins]) .
p . "Driver: " . textfield(-name=>'driver', -size=>'30') .
'  ' . "Contact: " . textfield(-name=>'contact', -size=>'30') .
p . "Number of students + adults: " . textfield(-name=>'total_number', -size=>'3') .
p . "Depart from: " . checkbox_group(-name=>'depart_from', -values=>['Gym','Theater']) .
p . "Division/Department: " . textfield(-name=>'division_department', -size=>'20') . "</div>" .

"<div style=\"border:1px solid black; padding:5px; margin:20px 0 20px 0;\"><b>Optional Information</b>" .
p . "Rental vehicle types (e.g., minivan, SUV, cargo van): " . textfield(-name=>'rental_vehicle_types', -size=>'40') .
p . "Other details: " . checkbox_group(-name=>'other_details', -values=>['Cargo van','Drop off only','Pick up only','Overnight trip']) .
p . "Special requests: " . textfield(-name=>'special_requests', -size=>'60') . "</div>" .
p . submit(-name=>'submit', -value=>'Submit Request') . hidden(-name=>'action') . endform;

$template =~ s/\$body/$output/;
$template =~ s/\$title/Request Transportation/g;
print header . $template;


sub save_form {

# check for empty minute fields
if (!param('depart_min')) {param(-name=>'depart_min', -value=>'00');}
if (!param('return_min')) {param(-name=>'return_min', -value=>'00');}

# convert dates to GMT
$depart_localtime = timelocal(0,param('depart_min'),param('depart_hour'),param('depart_day'),param('depart_month'),param('depart_year'));
$return_localtime = timelocal(0,param('return_min'),param('return_hour'),param('return_day'),param('return_month'),param('return_year'));
($s,$n,$h,$d,$m,$y) = gmtime($depart_localtime); $y+=1900;
$vcs_depart_time = $y . sprintf("%02d",$m) . sprintf("%02d",$d) . 'T' . sprintf("%02d",$h) . sprintf("%02d",$n) . sprintf("%02d",$s) . 'Z';
($s,$n,$h,$d,$m,$y) = gmtime($return_localtime); $y+=1900;
$vcs_return_time = $y . sprintf("%02d",$m) . sprintf("%02d",$d) . 'T' . sprintf("%02d",$h) . sprintf("%02d",$n) . sprintf("%02d",$s) . 'Z';

# format vcs file
PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN
LOCATION:" . param('destination') . "
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Activity: " . param('activity') . "=0D=0ADestination: " . param('destination') . "=0D=0ADepart time: " . param('depart_month') . "/" . param('depart_day') . "/" . param('depart_year') . " " . param('depart_hour') . ":" . param('depart_min') . "=0D=0AReturn time: " . param('return_month') . "/" . param('return_day') . "/" . param('return_year') . " " . param('return_hour') . ":" . param('return_min') . "=0D=0ADriver: " . param('driver') . "=0D=0AContact: " . param('contact') . "=0D=0ANumber of students + adults: " . param('total_number') . "=0D=0ADepart from: " . join(", ", param('depart_from')) . "=0D=0ADivision/Department: " . param('division_department') . "=0D=0ARental vehicle types: " . join(", ", param('rental_vehicle_types')) . "=0D=0AOther details: " . join(", ", param('other_details')) . "=0D=0ASpecial requests:" . param('special_requests') . "=0D=0A
SUMMARY:" . param('activity') . "

# send mail
$smtp = Net::SMTP->new('localhost');
$smtp->datasend("To: Transportation Coordinator\n");
$smtp->datasend("From: $fullname\n");
$smtp->datasend("Subject: Transportation request\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Disposition: attachment; filename=\"request.vcs\"\n");
$smtp->datasend("Content-Type: application/text; name=request.vcs\n");
$smtp->datasend($vcs . "\n\n");

# return html
$output = "Thank you. The transportation coordinator will review this request and then assign it to a vehicle. Please check the transportation calendar in a day or two to confirm your reservation.<P><a href=$cgiurl>Submit another transportation request</a>";
$template =~ s/\$body/$output/;
$template =~ s/\$title/Transportation Request Sent/g;
print header . $template;


Web Site Design Portfolio

This portfolio shows major sites I have designed and built for organizations.

Catlin Gabel School (2009-present)
The school’s main, public-facing website provides a complete content management system, multimedia publishing tools, user accounts for students, staff, parents, and alumni, and ties into the school’s student information system. A layer of the site is login-protected, so that community members may publish articles, photos, and videos to the school community.

Catlin Gabel website

Tools: Drupal and Blackbaud, including custom PHP development.


insideCatlin (2006-present)
This intranet web portal provides operational tools for the members of Catlin Gabel School. Teachers provide students with course materials and interactive discussion areas, departments publish commonly-used forms, and individuals schoolwide exchange information such as community service hours and textbook orders. The portal is organized by commonly-desired content and transactions, rather than by tool.


Tools used: Moodle, Drupal, Blackbaud database access, and custom Perl and PHP scripts.


Shasta Mountain Guides (2005 – present)
The guiding company uses this site to publish trip information, collect reservations, solicit customer questions, and sell merchandise. Customers may browse through trip descriptions, photos, and testimonials and then book a reservation online, including payment. The co-owners maintain the Backcountry Blog and photo galleries on the site. A live weather feed and equipment lists help hikers plan their trips.

Shasta Mountain Guides

Tools: Drupal, osCommerce, custom Perl scripts, custom graphic design


San Diego Hat Co (2001 – present)
This web site allows the company to quickly publish an online catalog of hundreds of items to wholesale customers twice each year. Within the login-protected site, customers browse or search for hat styles, zoom in to view close-up detail, and see available colors for each style. The site also includes static pages for company information and an online store for retail customers.

San Diego Hat Co

Tools: Web Site Baker, osCommerce, custom Perl scripts.


Maru-a-Pula School (2006 – present)
The school upgraded its web presence with a content management system and custom graphic design (Elavacion, Inc.). I moved the hosting service to the U.S., to improve upon the reliability of Botswana-based hosting services.

Tools used: Drupal


San Francisco University High School (2002 – 2006)
This site provided for all of the public-facing web site needs of this school community: a description of the school program, faculty and staff contact directory, admission inquiry toolkit, alumni profile and notes tools, and Arts department mini-site.

San Francisco University High School

Tools: Dreamweaver, custom Perl scripts.

insideUHS (2002-2006)
This intranet school portal provided the community with communication and information tools: course web sites, athletics schedules, community service project database, independent study project database, community announcements, schoolwide events calendar, student photo directories, online file access, and student discussion forums.

Tools: Moodle, YaBB, phpBB, FileMan, Blackbaud database access, custom Perl scripts.


site snapshot at The Internet Archive (original site no longer available)

Gateway High School (1999-2002)
The graphic design of this site communicates the school’s unique position as a public charter school in San Francisco. Learning Center and People receive high visibility, and student work is featured on the home page.

Gateway High School

Tools: Dreamweaver

www.gwhs.org at the Internet Archive