问题
I have two forms, a quotation and contact in ASP coding that no longer work from the updated server.
Both forms have the same ASP file that send me email. I thought I had a solution but not. I think as my file is encoded in ASP, and that the server is ASP.net, this creates conflict.
I seek a solution to receive emails again, by updating the ASP code I have now. I'm graphic designer and not a coder.
The specifications of my current server are:
Operating System WINDOWS
PHP Version 5.3
IIS Version IIS 7.0
.NET Version ASP.Net 2.0 / 3.0 / 3.5
To the contact form contact.asp encoding the first file is the following:
<%
response.expires=60
response.buffer=true
on error resume next
cat=6
amiblock=true
title="Contacter Artipik"
chemin="*<a href=contact.asp class=lienchemin>" & title & "</a>"
%>
<!--#include virtual="/commun/entete.asp"-->
<!--#include virtual="/commun/head.asp"-->
<script language="JavaScript" type="text/javascript">
<!--
function contactvalid(obj)
{
if (obj.nom.value=="")
{
alert("Merci de saisir votre nom");
obj.nom.focus();
return false;
}
if (obj.prenom.value=="")
{
alert("Merci de saisir votre pr�nom");
obj.prenom.focus();
return false;
}
if (obj.message.value.length<6)
{
alert("Merci de saisir un message d'au moins quelques mots...");
obj.message.focus();
return false;
}
if (!mailok.test(obj.email.value) || !mailok2.test(obj.email.value))
{
alert("Merci de saisir une adresse email valide");
obj.email.focus();
return false;
}
if (!mailok.test(obj.ami.value) || !mailok2.test(obj.ami.value))
{
alert("Merci de saisir une adresse email valide de votre ami");
obj.ami.focus();
return false;
}
}
// -->
</script>
<style type="text/css">
<!--
#tbcontact {width:340px;margin-top:20px;margin-bottom:40px;font-size:12px}
#coord {width:340px;border:1px solid #9a8199;text-align:left;font-size:16px;padding-top:0px;padding-bottom:0px}
#coord div{display:block;margin:10px}
#carte {width:340px;height:400px;border:2px solid #CCCCCC;margin-top:10px}
form {margin:0;padding:0}
.saisie {width:240px;border:1px solid #9a8199;font-size:12px;color:#8b6158;font-family:Arial,Verdana,Helvetica,sans-serif}
form textarea{width:240px;border:1px solid #9a8199;font-size:12px;color:#8b6158;font-family:Arial,Verdana,Helvetica,sans-serif}
/*input[type=radio]{width:300px;border:1px solid #9a8199;font-size:12px;color:#8b6158;font-family:Arial,Verdana,Helvetica,sans-serif}*/
-->
</style>
<!--#include virtual="/commun/bandohaut.asp"-->
<!--#include virtual="/upload/coord.asp"-->
<div style="margin:20px">
<img src="/images/pucelosange.gif" width="18" height="14" border="0"><span class="titrerub">CONTACTEZ-NOUS</span><br>
<img src="/images/separebicolore2.gif" width="688" height="6" border="0" vspace=3><br>
<div style="width:688px;text-align:right">* champs obligatoires </div>
<% If affich_map=1 then %>
<div style="position:absolute;margin-top:20px;margin-left:348px">
<div id="coord">
<% If coord_adresse<>vbnullstring then %><div><span class=titrerose><img src="/images/pucerose.gif" width="8" height="8" border="0"> Show-room</span> <span style="font-size:11px"><i>(sur rendez-vous)</i></span><br><%= coord_adresse %></div><% End If %>
<% If coord_metro<>vbnullstring then %><div><span class=titrerose><img src="/images/pucerose.gif" width="8" height="8" border="0"> M�tro / RER</span><br><%= coord_metro %></div><% End If %>
<% If coord_bus<>vbnullstring then %><div><span class=titrerose><img src="/images/pucerose.gif" width="8" height="8" border="0"> Bus</span><br><%= coord_bus %></div><% End If %>
<% If feuvert then %>
<span class=titrerose><img src="/images/pucerose.gif" width="8" height="8" border="0"> T�l�phone</span><br><%= coord_tel %><br>
<span style="font-size:10px">(prix d'un appel local en France)</span><br><br>
<span class=titrerose><img src="/images/pucerose.gif" width="8" height="8" border="0"> Mobile</span><br><%= coord_mobile %>
<% End If %>
</div>
<div id="carte">
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAgKoL5za6CVbLQHrHSdRGPRQniikd0iliF4ChcQSNayNSO4Cr3hQBQSq4du-gpuF6FeDeS2ymuDlJAA" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
var gadresse=new GLatLng(48.6774691,2.3551995)
var map = new GMap2(document.getElementById("carte"),{size: new GSize(340,400)});
map.setCenter(gadresse, 15);
map.addOverlay(new GMarker(gadresse));
map.addControl(new GSmallMapControl());
}
}
initialize();
</script>
</div>
</div>
<% End If %>
<form name="contact" action="contactprocess.asp" method="post" target=process onSubmit="return contactvalid(this)">
<table border=0 cellpadding=0 cellspacing=0 id="tbcontact"<% If affich_map<>1 then response.write(" align=center") %>>
<tr>
<tr height=25>
<td width=80 align=right>Civilit�</td>
<td width=260 align=center>
<input type="radio" name="civil" value="Mr" checked>Mr
<input type="radio" name="civil" value="Mme">Mme
<input type="radio" name="civil" value="Mlle">Mlle
</td></tr>
<tr height=30>
<td align=right><strong>*</strong> Nom</td><td align=center><input type="text" name="nom" class="saisie"></td>
</tr>
<tr height=30>
<td align=right><strong>*</strong> Pr�nom</td><td align=center><input type="text" name="prenom" class="saisie"></td></tr>
<tr height=30>
<td align=right>Adresse</td><td align=center><input type="text" name="adresse" class="saisie"></td></tr>
<tr height=30>
<td align=right>Code Postal</td><td align=center><input type="text" name="cp" class="saisie"></td></tr>
<tr height=30>
<td align=right>Ville</td><td align=center><input type="text" name="ville" class="saisie"></td></tr>
<tr height=30>
<td align=right>Pays</td><td align=center><input type="text" name="pays" class="saisie"></td></tr>
<tr height=30>
<td align=right><strong>*</strong> Email</td><td align=center><input type="text" name="email" value="<%= request.cookies("email") %>" class="saisie"></td></tr>
<tr height=30>
<td align=right>T�l�phone</td><td align=center><input type="text" name="tel" class="saisie"></td></tr>
<tr height=40>
<td align=right>Vous �tes</td>
<td align=center>
<select name="ki" class="saisie">
<option>Visiteur
<option>Client
<option>Entreprise
<option>Artiste
<option>Agent
<option>Journaliste
<option>Partenaire
<option value="">Autre
</select>
</td></tr>
<tr valign=top>
<td align=right>Message</td>
<td align=center><textarea name="message" wrap="virtual" style="width:240px;height:225px;overflow-y:auto" onKeyUp="if(this.value.length>600){alert('Pas plus de 600 caract�res, merci !');this.value=this.value.substring(0,600)}"></textarea></td></tr>
<tr>
<td align=right></td>
<td align=center><input type="image" src="/images/btn_envoyer.gif" alt="Envoi du message" title="Envoyer votre message" width="103" height="26" vspace=8></td></tr>
</table>
</form>
</div>
<!--#include virtual="/commun/bandobas.asp"-->
Then the second part of the coding in the file contactprocess.asp:
<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
on error resume next
%>
<!--#include virtual="/upload/coord.asp"-->
<%
envoyeur="visiteur@artipik.com"
receveur=coord_email
askeur=replace(request.form("email"),"@"," (arob) ")
askeur=replace(askeur,"."," (point) ")
'copie="stefanium@hotmail.com"
nom=request.form("nom")
prenom=request.form("prenom")
message=request.form("message")
adresse=request.form("adresse")
cp=request.form("cp")
ville=request.form("ville")
pays=request.form("pays")
tel=request.form("tel")
ki=request.form("ki")
if envoyeur=vbnullstring or message=vbnullstring or nom=vbnullstring or prenom=vbnullstring then response.end
sujet="ARTIPIK.com | Contact : " & ucase(nom) & " " & prenom
'on compile le message...
entete="Exp�diteur : " & request.form("civil") & " " & ucase(nom) & " " & prenom & vbcrlf
entete=entete & "Email de r�ponse : " & askeur & vbcrlf
if adresse<>vbnullstring then entete=entete & "Adresse : " & adresse & vbcrlf
if cp<>vbnullstring then entete=entete & "Code postal : " & cp & vbcrlf
if ville<>vbnullstring then entete=entete & "Ville : " & ville & vbcrlf
if pays<>vbnullstring then entete=entete & "Pays : " & pays & vbcrlf
if tel<>vbnullstring then entete=entete & "T�l. : " & tel & vbcrlf
if ki<>vbnullstring then entete=entete & "Cat�gorie : " & ki & vbcrlf
entete=entete & vbcrlf & "-----------------------------------------------------------------" & vbcrlf & vbcrlf & "MESSAGE :" & vbcrlf & vbcrlf
message=left(message,600)
message=entete & message
%>
<!--#include virtual="/commun/envoimail.asp"-->
<html>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
<% If err.number=0 then %>
parent.contact.message.value='';alert("Votre message a bien �t� envoy�.\nVous recevrez une r�ponse sous peu...\t");
<% Else %>
alert("Probl�me de serveur :\n<%= replace(err.description,"'","\'") %>\n\nMerci de r�-essayer plus tard.\t");
<% End If %>
location.href="about:blank";
// -->
</SCRIPT>
</body>
</html>
And finally the last part of the current code on the server, in the envoimail.asp file is as follows:
<%
'-----version CDONTS-----
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.BodyFormat = 1 '0:html/1:plain text
Mail.MailFormat = 1 '0:MIME/1:plain text
Mail.From = envoyeur
Mail.To = receveur
if copie<>vbnullstring then Mail.Bcc = copie
if sujet=vbnullstring then sujet="Formulaire de contact Artipik.com"
Mail.Subject = sujet
Mail.Body = message
Mail.Send
set Mail=Nothing
'response.cookies("email")=envoyeur
%>
回答1:
CDONTS is really old, it was deprecated in Windows 2000 and removed completely from Windows 2003. CDO is the standard component for sending emails in classic ASP.
The equivalent code to your example would be something like this.
<%
Set Mail = Server.CreateObject("CDO.Message")
Mail.From = envoyeur
Mail.To = receveur
if copie<>vbnullstring then Mail.Bcc = copie
if sujet=vbnullstring then sujet="Formulaire de contact Artipik.com"
Mail.Subject = sujet
Mail.TextBody = message
Mail.Send
set Mail=Nothing
%>
Mail.Textbody
specifies that the message is in plaintext format. For an HTML email you would use Mail.HtmlBody
.
CDO allows you to use a remote SMTP server, CDONTS did not. Depending on the setup of your SMTP server you may need to add server configuration details. I recommend this tutorial.
http://www.powerasp.net/content/new/sending_email_cdosys.asp
来源:https://stackoverflow.com/questions/30350999/new-asp-code-for-contact-email-form-on-godaddy-server