in reply to Cdont's Type Mismatch

It may be that somehow you failed to post all the code -- the error message cites "line 167" of the perl script, but when I loaded that code into my own text editor, there were only about 105 lines.

Could you please figure out, using your own text editor and your own copy of the code, where line 167 is? If that line is included in the code that you have posted, please indicate which line it was. (If you didn't originally post all the code, please be sure to show us the part that is causing the error.)

As a wild guess, if the line causing the error happens to be this one:

$objMail->Send($from,$to,$subject,$mailbody,$AttachFile);
then maybe you need to do some sanity checking on the contents of the variables being passed to this method, before you pass them to the method. (Since these values are coming from a CGI form, you should most likely be doing some taint checking on them as well.)

Hmm... just noticed that you seem to be using the same email address for both the "$from" and the "$to" args for $objMail->Send -- this might lead some folks to think that you are a spammer.

Replies are listed 'Best First'.
Re: Re: Cdont's Type Mismatch
by Rafiq (Initiate) on Feb 26, 2003 at 12:11 UTC
    I cut out a bunch of the code that wasn't necessary. Once I addd the $AttachFile part this when I get the error. Youwere correct about the line with the error here is the whole code:
    #! /Perl/bin/perl $|=1; use diagnostics; use vars; use CGI qw(:standard); use Win32::OLE; $q = new CGI; # The following accepts the data from the form print"Content-type: text/html\n\n"; $LastName = param('LastName'); # $FirstName = param('FirstName'); # $MiddleName = param('MiddleName'); # $Email_address = param('Email_address'); # $Area = param('Area'); # $Prefix = param('Prefix'); # $Number = param('Number'); # $Address = param('Address'); # $City = param('City'); # $State = param('State'); # $Zip = param('Zip'); # $Code = param('Code'); # $Grad = param('Grad'); # $HighSchool = param('HighSchool'); # $tmpfile = "../../Temp/$$.htm"; $dir = "../../Temp/RRX"; $dirfile = ""; $filexist = 0; @dirfiles = (); $file = "seminar.txt"; $Phone = join('-',$Area,$Prefix,$Number); @seminarfile = join('^',$LastName,$FirstName,$MiddleName,$Email_addres +s, $Phone,$Address,$City,$State,$Zip,$Code,$Grad,$HighSchool); ############# check to see if seminar.txt exists ##################### +######### opendir(DIR, "$dir") || die "Can't open $dir: $!\n"; @dirfiles = readdir DIR; closedir(DIR); foreach $dirfile(@dirfiles) { if($dirfile eq $file){$filexist = "1"} } if($Grad == "2004"){ #The following creates the Thank You page display print start_html('Thank You'); print start_form(); print "<body text=\"#ffffff\" vlink=\"#ffff00\" alink=\"\#ff0000\" lin +k=\"#00ffff\""; print "bgcolor=\"#ffffff\" background=\"../Summer/USAFAfiles/backgroun +d.jpg\">"; print "<table cellspacing=\"0\" cellpadding=\"0\" align=\"center\" bor +der=\"0\">"; print "<tbody><tr><td valign=\"top\" width=\"163\" height=\"1\"><br></ +td>"; print "<td valign=\"top\" width=\"5\" height=\"1\"><br></td>"; print "<td valign=\"top\" width=\"516\" height=\"1\"><br></td>"; print "<td valign=\"top\" width=\"4\" height=\"1\"><br></td>"; print "<td valign=\"top\" width=\"167\" height=\"1\"><br></td></tr><tr +>"; print "<td valign=\"top\" width=\"163\" height=\"173\" rowspan=\"3\">" +; print "<p align=\"center\"><a href=\"http:\/\/www.usafa.af.mil\/\"><im +g"; print " height=\"175\" src=\"../Summer/USAFAfiles\/SEAL1\-transB.gif\" + width=\"160\" border=\"0\""; print " alt=\"United States Air Force Academy Web Page\">"; print "</a><br><a href=\"http:\/\/www.usafa.af.mil\/\">Back to USAFA</ +a></p></td>"; print "<td valign=\"top\" width=\"5\" height=\"6\"><br></td>"; print "<td valign=\"top\" width=\"516\" height=\"6\"><br></td>"; print "<td valign=\"top\" width=\"4\" height=\"6\"><br></td>"; print "<td valign=\"top\" width=\"167\" height=\"6\"><br></td></tr><tr +>"; print "<td valign=\"top\" width=\"5\" height=\"17\"><br></td>"; print "<td valign=\"top\" width=\"516\" height=\"17\"><br></td>"; print "<td valign=\"top\" width=\"4\" height=\"17\"><br></td>"; print "<td valign=\"top\" width=\"167\" height=\"167\" rowspan=\"2\">< +br></td></tr><tr>"; print "<td valign=\"top\" width=\"5\" height=\"150\"><br></td>"; print "<td valign=\"top\" width=\"516\" height=\"150\">"; + print "<div align=\"center\"><font face=\"Arial, Helvetica, sans-serif +\""; print "color=\"\#ffffff\"><b><font face=\"Arial\" size=\"5\">UNITED ST +ATES AIR FORCE"; print " ACADEMY</font></b></font></div><hr align=\"center\" width=\"45 +0\" size=\"1\">"; print "<div align=\"center\"><h2><br>Summer Seminar \&nbsp\;'03 &nbsp; +Information Request<br>"; print "<font size=\"3\">Thank you $FirstName $LastName for your reques +t.</font></h2></div></td>"; print "<td valign=\"top\" width=\"4\" height=\"150\"><br></td></tr><tr +>"; print "<td valign=\"top\" width=\"855\" colspan=\"5\" height=\"598\">" +; print "<div align=\"left\"><font color=\"\#ff0000\"><u><i><b><font siz +e=\"5\"><br>"; print "Only High School Juniors may apply</font></b></i></u></font><br +>"; print "</div><p><table width=\"99\%\" border=\"1\"><tbody><tr>"; print "<td width=\"16\%\" align=\"center\" valign=\"middle\"><b><font" +; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>Last Name</b></td>"; print "<td width=\"18\%\" align=\"center\" valign=\"middle\"><b>\&nbsp +\;<font"; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>First Name</b></td>"; print "<td width=\"19\%\" align=\"center\" valign=\"middle\"><b>Middle + Name</b></td>"; print "<td width=\"17\%\" align=\"center\" valign=\"middle\">\*<b>E-ma +il Address</b><br></td>"; print "<td width=\"30\%\" align=\"center\" valign=\"middle\"><b>Home P +hone</b><br></td></tr><tr>"; print "<td width=\"16\%\" align=\"center\" valign=\"middle\">$LastName +<br></td>"; print "<td width=\"18\%\" align=\"center\" valign=\"middle\">$FirstNam +e<br></td>"; print "<td width=\"19\%\" align=\"center\" valign=\"middle\">$MiddleNa +me<br></td>"; print "<td width=\"17\%\" align=\"center\" valign=\"middle\">$Email_ad +dress<br></td>"; print "<td width=\"30\%\" align=\"center\" valign=\"middle\">$Area - $ +Prefix - $Number<br></td></tr>"; print "</tbody></table><br><table width=\"100\%\" border=\"1\" height= +\"164\"><tbody><tr>"; print "<td width=\"24\%\" height=\"28\" align=\"center\" valign=\"midd +le\"><b><font"; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>Mailing Address</b></td>"; print "<td width=\"21\%\" height=\"28\" align=\"center\" valign=\"midd +le\"><b><font"; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>City</b></td>"; print "<td height=\"28\" width=\"32\%\" align=\"center\" valign=\"midd +le\"><b><font"; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>State or"; print " Country</b></td>"; print "<td width=\"23\%\" height=\"28\" align=\"center\" valign=\"midd +le\"><b><font"; print " face=\"Georgia, Times New Roman, Times, serif\" size=\"4\">\*< +/font>Zip\&nbsp\;Code</b></td>"; print "</tr><tr><td width=\"24\%\" height=\"43\" align=\"center\" vali +gn=\"middle\">$Address<br></td>"; print "<td width=\"21\%\" height=\"43\" align=\"center\" valign=\"midd +le\">$City<br></td>"; print "<td height=\"43\" width=\"32\%\" align=\"center\" valign=\"midd +le\">$State<br></td>"; print "<td width=\"22\%\" height=\"43\" align=\"center\" valign=\"midd +le\">"; print "$Zip</td></tr><tr>"; print "<td width=\"24\%\" height=\"21\" align=\"center\" valign=\"midd +le\">"; print "<b>High School ETS Code</b><br></a></td>"; print "<td width=\"21\%\" height=\"21\" align=\"center\" valign=\"midd +le\">\*"; print "<b>Year of Graduation</b><br></td>"; print "<td height=\"21\" width=\"32\%\" align=\"center\" valign=\"midd +le\">\*<b>"; print "High School Name</b></td><td width=\"22%\" height=\"21\"><br></ +td></tr><tr>"; print "<td width=\"24\%\" height=\"31\"><div align=\"center\">"; print "$Code<br></div></td>"; print "<td width=\"21\%\" height=\"31\"><div align=\"center\">"; print "$Grad<br></div></td>"; print "<td height=\"31\" width=\"32\%\"><div align=\"center\">$HighSch +ool<br></div></td>"; print "<td width=\"23\%\" height=\"31\"><br></td></tr><tr>"; print "<td width=\"24\%\" height=\"31\"><div align=\"center\"><b>"; print "If you are home schooled, enter \"000000\" as your school code. +</b></div>"; print "</td></tr></tbody></table></p><br>"; print "<p align=\"center\"><b>\&nbsp\;Privacy and Security Notice</a>< +/b></p>"; print "<hr><br>"; print "<div align=\"center\"><a href=\"mailto:RRI.Web\@usafa.af.mil\" +style=\"text-decoration: none;\">"; print "<b>USAFA/RRI</b></a></div>"; print "</td></tr></tbody><tbody><tr>"; print "<td valign=\"top\" width=\"163\" height=\"1\"><img height=\"1\" + src=\"../Summer/USAFAfiles/transparent.gif\" width=\"163\">"; print "</td><td valign=\"top\" width=\"5\" height=\"1\"><img height=\" +1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"5\">"; print "</td><td valign=\"top\" width=\"516\" height=\"1\"><img height= +\"1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"516\">"; print "</td><td valign=\"top\" width=\"4\" height=\"1\"><img height=\" +1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"4\">"; print "</td><td valign=\"top\" width=\"167\" height=\"1\"><img height= +\"1\" src=\"USAFA/transparent.gif\" width=\"167\">"; print "</td></tr></tbody></table><br>"; print end_form(); print end_html(); add(); email_msg(); send_win_mail(); } ############# sends mail to persons ################################# +######### sub send_win_mail { my $from = $q->param('Email_address'); my $to = ("$Email_address"); my $subject = qq(Summer Seminar '04 Information Request); my $date = localtime(time); my $mailbody = "$FirstName $LastName submitted an Summer Seminar Appli +cation Request on $date: \n\n"; my $AttachFile = "$tmpfile"; my $objMail = Win32::OLE->new("CDONTS.Newmail"); $objMail->Send($from,$to,$subject,$mailbody,$AttachFile); undef $objMail; unlink($tmpfile) || die "Can't delete $tmpfile: $!"; # Deletes the file created in /tmp/html exit(0); } sub email_msg { open(OUT, ">$tmpfile") || die "Can't write $tmpfile: $!\n "; print OUT "test"; close(OUT); } ################# creates new file or adds to existing file ######## +####### sub add{ if($filexist == 1) { open(IN, "< $dir/$file") or die "Can't open input file $file: +$!\n"; chomp(@filearray = <IN>); close(IN); push(@filearray, @seminarfile); } elsif($filexist == 0) {push(@filearray, @seminarfile)} open(OUT, "> $dir/$file") or die "Can't write to $file: $!\n"; foreach $line(@filearray) { chomp $line; print OUT "$line\n"; } close(OUT); } #If applicant does not meet criteria print start_html('Wrong Grad Year'); print start_form(); print "<body bgcolor=\"\#fffff\f\" text=\"\#ffffff\" background=\"../S +ummer/USAFAfiles/background.jpg\""; print " link=\"\#00ffff\" vlink=\"\#ffff00\" alink=\"\#ff0000\">"; print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\ +"center\">"; print "<tbody><tr><td width=\"163\" height=\"1\" valign=\"top\"><br>< +/td>"; print "<td width=\"5\" height=\"1\" valign=\"top\"><br></td>"; print "<td width=\"516\" height=\"1\" valign=\"top\"><br></td>"; print "<td width=\"4\" height=\"1\" valign=\"top\"><br></td>"; print "<td width=\"167\" height=\"1\" valign=\"top\"><br></td></tr><t +r>"; print "<td width=\"163\" height=\"173\" rowspan=\"3\" valign=\"top\"> +"; print "<p align=\"center\"><a href=\"http:\/\/www.usafa.af.mil/\"><im +g src="; print "\"../Summer/USAFAfiles/SEAL1\-transB.gif\" width=\"160\" height +=\"175\" border=\"0\">"; print "</a><br><a href=\"http:\/\/www.usafa.af.mil/\">Back to USAFA</ +a></p></td>"; print "<td width=\"5\" height=\"6\" valign=\"top\"><br></td>"; print "<td width=\"516\" height=\"6\" valign=\"top\"><br></td>"; print "<td width=\"4\" height=\"6\" valign=\"top\"><br></td><td width +=\"167\" height=\"6\" valign=\"top\"><br>"; print "</td></tr><tr><td width=\"5\" height=\"17\" valign=\"top\"><br +></td>"; print "<td width=\"516\" height=\"17\" valign=\"top\"><br></td>"; print "<td width=\"4\" height=\"17\" valign=\"top\"><br></td>"; print "<td width=\"167\" height=\"167\" rowspan=\"2\" valign=\"top\"> +<br></td></tr><tr>"; print "<td width=\"5\" height=\"150\" valign=\"top\"><br></td><td wid +th=\"516\" height=\"150\" valign=\"top\">"; print "<div align=\"center\"><font color=\"\#ffffff\" face=\"Arial, H +elvetica, sans-serif\">"; print "<b><font size=\"5\" face=\"Arial\">UNITED STATES AIR FORCE ACAD +EMY</font></b></font></div>"; print "<hr size=\"1\" width=\"450\" align=\"center\"><div align=\"cen +ter\">"; print "<h2><br></h2></div></td><td width=\"4\" height=\"150\" valign= +\"top\"><br></td></tr><tr>"; print "<td width=\"855\" height=\"598\" colspan=\"5\" valign=\"top\"> +"; print "<div align=\"center\"><p></p><big><big><b><br><br>"; print "At the present time $FirstName $LastName you do not meet <br>"; print "Summer Seminar Request criteria."; print "<br> You are only allowed to request information if you"; print " <br> are a JUNIOR in High School.<br>"; print " Thank You.</b></big></big><br>"; print "<p><br></p><p><br></p><p><br></p><hr><br>"; print "<div align=\"center\"><a href=\"mailto:RRI.Web\@usafa.af.mil\" + style=\"text-decoration: none;\">"; print "<b>USAFA/RRI</b></a></div>"; print "</td></tr></tbody><tbody><tr>"; print "<td valign=\"top\" width=\"163\" height=\"1\"><img height=\"1\ +" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"163\">"; print "</td><td valign=\"top\" width=\"5\" height=\"1\"><img height=\ +"1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"5\">"; print "</td><td valign=\"top\" width=\"516\" height=\"1\"><img height +=\"1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"516\">"; print "</td><td valign=\"top\" width=\"4\" height=\"1\"><img height=\ +"1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"4\">"; print "</td><td valign=\"top\" width=\"167\" height=\"1\"><img height +=\"1\" src=\"../Summer/USAFAfiles/transparent.gif\" width=\"167\">"; print "</td></tr></tbody></table><br>"; print end_form(); print end_html(); exit(0);