Optimering af kode
Her har jeg noget rodet kode som der er en fejl:Variable is undefined: \'conn\'
/mail/spaw1.asp, line 27
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<html>
<head>
<title>xxx</title>
</head>
<body bgcolor=#ffffff>
<%
Dim strName, strEmail, strQuery, strAdresse, strBy, strTlf, strTlfArbejde, strSagsnr, strSalgsopstilling, strArcrive
strName = Trim(Request.Form(\"ClientName\"))
strAdresse = Trim(Request.Form(\"ClientAdresse\"))
strBy = Trim(Request.Form(\"ClientBy\"))
strTlf = Trim(Request.Form(\"ClientTlf\"))
strTlfArbejde = Trim(Request.Form(\"ClientTlfArbejde\"))
strEmail = Trim(Request.Form(\"ClientEmail\"))
strQuery = Trim(Request.Form(\"ClientQry\"))
strSagsnr = Trim(Request.Form(\"ClientSagsnr\"))
strSalgsopstilling = Trim(Request.Form(\"ClientSalgsopstilling\"))
strArcrive = Trim(Request.Form(\"ClientArcrive\"))
If (strName <> \"\") Then
Dim objMail, aRecipients
if strArcrive = \"1\" then
set conn=Server.CreateObject(\"ADODB.Connection\")
conn.Provider=\"Microsoft.Jet.OLEDB.4.0\"
conn.Open(Server.Mappath(\"SpawnedMailer.mdb\"))
set rsMail = Server.CreateObject(\"ADODB.recordset\")
rsMail.Open \"SELECT * FROM MailingList WHERE MailingAddy=\'\" & strEmail & \"\'\", conn
If not rsMail.EOF Then
If rsMail(\"MailingAddy\") = strEmail Then
End if
Else
ArchiveSQL = \"INSERT into MailingList (MailingAddy) VALUES (\'\" & strEmail & \"\');\"
conn.Execute ArchiveSQL
end if
rsMail.close
conn.close
end if
Set objMail = Server.CreateObject(\"CDONTS.NewMail\")
objMail.From = \"11@11.dk\"
objMail.To = strEmail
objMail.Subject = \"ddd! \"
objMail.AttachFile Server.MapPath (strSalgsopstilling)
objMail.Body = \"!!!! \"
objMail.Send
Response.Write \"Tak for din bestilling ! \" & strName
Set objMail = Nothing
Else
%>
<FORM ACTION=\"<%=Request.ServerVariables(\"SCRIPT_NAME\")%>\" METHOD=POST>
<div align=\"center\">
<center>
<TABLE BORDER=0 width=\"550\">
<tr><td width=\"530\" colspan=\"6\">Du har valgt at bestille en sag på :</td></tr>
</center>
<tr><td width=\"102\" colspan=\"2\">
</td>
<td width=\"428\" colspan=\"4\"></td></tr>
<tr><td width=\"102\" colspan=\"2\">
</td>
<td width=\"428\" colspan=\"4\"></td></tr>
<tr><td width=\"102\" colspan=\"2\" align=\"right\">
<p align=\"right\"></td>
<center>
<td width=\"95\" align=\"right\"><b>Sagsnr</b>:</td>
<td width=\"333\" colspan=\"3\"><input type=\"text\" name=\"ClientSagsnr\" size=\"12\" value=\"<%=request.querystring(\"Sagsnr\")%>\" style=\"font-weight: bold; border-style: solid; border-color: #FFFFFF\"></td></tr>
</center>
<tr><td width=\"102\" colspan=\"2\" align=\"right\">
<p align=\"right\"></td>
<center>
<td width=\"96\" align=\"right\"><b>Beliggenhed</b>:</td>
<td width=\"333\" colspan=\"3\"><input type=\"text\" name=\"ClientBeliggenhed\" size=\"39\" value=\"<%=request.querystring(\"Beliggenhed\")%>\" style=\"font-weight: bold; border-style: solid; border-color: #FFFFFF\"></td></tr>
<tr><td width=\"91\"></td><td width=\"11\"></td><td width=\"428\" colspan=\"4\"></td></tr>
<tr><td width=\"530\" colspan=\"6\">
</td></tr>
<tr><td width=\"530\" colspan=\"6\">
</td></tr>
<tr><td width=\"530\" colspan=\"6\">
</td></tr>
<tr><td width=\"530\" colspan=\"6\">
</td></tr>
<tr><td width=\"530\" colspan=\"6\">
Når din bestilling er sendt, får du øjeblikkelig salgsopstillingen
på din e-mail.<br>
sagen sendes i PDF-format <input type=\"HIDDEN\" name=\"ClientSalgsopstilling\" size=\"9\" value=\"<%=request.querystring(\"Salgsopstilling\")%>\" style=\"font-size: 8 pt; border-style: solid\"></td></tr>
<tr><td width=\"530\" colspan=\"6\"></td></tr>
<tr><td width=\"530\" colspan=\"6\"></td></tr>
<tr><td width=\"530\" colspan=\"6\"></td></tr>
<tr><td width=\"530\" colspan=\"6\"></td></tr>
<tr><td width=\"530\" colspan=\"6\">
sagen skal sendes til :</td></tr>
<tr><td width=\"91\">Navn:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><INPUT NAME=\"ClientName\" VALUE=\"\" SIZE=57 tabindex=\"1\"></td></tr>
<tr><td width=\"91\">Adresse:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientAdresse\" size=\"57\" tabindex=\"2\"></td></tr>
<tr><td width=\"91\">Postnr. og by:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientBy\" size=\"57\" tabindex=\"3\"></td></tr>
<tr>
<td width=\"91\">Tlf:</td><td width=\"11\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientTlf\" size=\"18\" tabindex=\"4\">Tlf (arbejde/mobil):<input type=\"text\" name=\"ClientTlfArbejde\" size=\"20\" tabindex=\"5\"></td>
</tr>
<tr><td width=\"91\">e-mail adresse</td><td width=\"11\"></td><td width=\"428\" colspan=\"4\"><INPUT NAME=\"ClientEmail\" SIZE=57 tabindex=\"6\"></td></tr>
<tr><td width=\"91\"></td><td width=\"11\"></td>
</center>
<td width=\"428\" colspan=\"4\">
<p align=\"left\">Få automatisk opdatering og nyhedsbrev
tilsendt Ja<input type=\"radio\" value=\"1\" checked name=\"ClientArcrive\">
Nej<input type=\"radio\" name=\"ClientArcrive\" value=\"0\"></td></tr>
<center>
<tr><td width=\"91\"></td><td width=\"11\"></td><td width=\"94\"></td><td width=\"90\"></td><td width=\"16\"></td><td width=\"220\"></td></tr>
<tr><td width=\"91\"></td><td width=\"11\"></td><td width=\"94\"><INPUT TYPE=SUBMIT VALUE=\"Send\" tabindex=\"7\"></td><td width=\"90\"></td><td width=\"16\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\" align=\"right\"></td><td width=\"220\">skal
udfyldes</td></tr>
<tr><td width=\"302\" colspan=\"5\"></td><td width=\"220\"></td></tr>
<tr><td width=\"302\" colspan=\"5\"></td><td width=\"220\"></td></tr>
<tr><td width=\"522\" colspan=\"6\">
Hvis du ikke udfylder feltet e-mail eller ikke har har e-mail,
vil sagen blive tilsendt pr. post.</td></tr>
<tr><td width=\"522\" colspan=\"6\"></td></tr>
</TABLE>
</center>
</div>
</FORM>
<% End If %>
<div align=\"center\">
<center>
<table border=\"0\" cellspacing=\"1\" width=\"550\">
<tr>
<td width=\"495\" height=\"77\">
<p style=\"word-spacing: 0; margin: 0\">xx
<p style=\"word-spacing: 0; margin: 0\"><br>
For at kunne læse salgsopstillingen via e-mail, skal du have
installeret Acrobat Reader 4.0 på din maskine. Har du ikke Acrobat
Reader installeret, kan du hente programmet gratis her på siden, ved
at klikke på ikonet. Programmet skal kun hentes og installeres én
gang.<br>
</td>
</tr>
<tr>
<td width=\"495\" height=\"77\" valign=\"top\">
<p align=\"center\"><a href=\"http://www.adobe.dk/adobe\" target=\"_blank\"><img src=\"../images/getacro.gif\" border=\"0\"></a>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>