webForumDet fria alternativet

CDONTS och förlorade mail

ASP

2 svar · 245 visningar · startad av timedia

Medlem sedan maj 2001420 inlägg
Frågan#1

Har hittat ett exempel som jag kör utan problem.
Jag kommer fram till 'tacksidan' där det står att mailet är skickad. Tyvärr kommer det inte fram och efter att ha pratat med ägaren av servern står det klart att det inte ligger där. Var har mailet tagit vägen?

 TEST2.ASP
<html>

<head><title>Mail Input Page</title></head>

<body>

<form method='post' action='sendmail.asp' name='Inputform'>

<table border='1' width='50%'>

<tr><td width='48%'>From</td>

<td width='52%'>&nbsp;<input type='text' name='From' size='20'></td></tr>

<tr><td width='48%'>To</td><td width='52%'><input type='text' name='to' size='20'></td></tr>

<tr><td width='48%'>Subject</td><td width='52%'><input type='text' name='subject' size='20'></td></tr>

<tr><td width='48%'>Body</td><td width='52%'><input type='text' name='body' size='20'></td></tr>

<tr><td width='48%'><input type='submit' value='Send' name='B1'><input type='reset'value='Reset' name='B2'></td>

<td width='52%'>&nbsp;</td></tr>

</table>

</form>

</body>

</html>

sendmail.asp

<%

'Declare local variables to hold the data from the Input form page that is used above.

Dim strTo

Dim strSubject 

Dim strBody 'Strings for recipient, subject, boby

Dim objCDOMail 'The CDO object

'First read in the values entered from the form into the Local variables

strFrom = Request.Form("From") 'Make sure the From field has no spaces. 

strTo = Request.Form("to")

strSubject = Request.Form("subject")

strBody = Request.Form("body")

' Create an instance of the NewMail object.

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

' Set the properties of the object

objCDOMail.From = StrFrom

objCDOMail.To = strTo

objCDOMail.Subject = strSubject

objCDOMail.Body = strBody

Set objCDOMail = Nothing    

%>

<html>

<head><title>Sent Mail</title></head>

<body>

Your mail was sent to:<% = request("to") %><br>

The time that is was sent was: <% = Now %>

</body>

</html>
Medlem sedan maj 2001420 inlägg
#2

Fixat.
saknade en viktig rad:
objCDOMail.Body.Send

MEN nu när jag har konstaterat att ovanstående exempel funkar, så vill jag förstås använda det riktiga formuläret.

<%
'Declare local variables to hold the data from the Input form page that is used above.
Dim strTo
Dim strSubject 
Dim strBody 'Strings for recipient, subject, boby
Dim objCDOMail 'The CDO object

'First read in the values entered from the form into the Local variables
strFrom = Request.Form("email") 'Make sure the From field has no spaces. 
strTo = "mathias@tltkommunikation.se" 'original: Request.Form("to")
strSubject = "mail från hemsidan" 'original:Request.Form("subject")
strBox = Request.Form("box")
strText = Request.Form("text")
strNamn = Request.Form("name")
strForetag = Request.Form("foretag")
strEpost = Request.Form("email")
strTelefon = Request.Form("telefon")
strFax = Request.Form("fax")
strAdress = Request.Form("adress")
strBody = Request.Form("text")
' Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
' Set the properties of the object
objCDOMail.From = StrFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
[B]objCDOMail.Body = "Vill ha info om: " & strBox &_[/B]
"Namn:" & strNamn & vbcrlf &_
"Företag:" & strForetag & vbcrlf &_
"E-mail:" & strEpost & vbcrlf &_
"Telefon:" & strTelefon & vbcrlf &_
"Fax:" & strFax & vbcrlf &_
"Adress:" & strAdress & vbcrlf &_
"Annat:" & strText & vbcrlf &_
objCDOMail.Send

Set objCDOMail = Nothing    

%>

MEN här blir det Internal Server Error - ASP error
Error Type:
(0x80040108)
/tack.asp, line 150

line 150 markerad med fet text

Medlem sedan maj 2001420 inlägg
#3

Peer rekommenderade att ta bort &_ i raden
"Annat:" & strText & vbcrlf &_
..och nu funkar det bra :) Tack Peer!

265 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
131 ms — deklarationer (db)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)
130 ms — ändringar (db)