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?
<%
'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>
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