Om du kör asp och jmail på din webserver kan du göra följande.
Html
Kod:
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="script.asp" method="post">
Namn: <input type="text" name="firstanme" /><br />
Efternamn: <input type="text" name="lastname" /><br />
...<br />
Ärende:
<select name="mailto">
<option value="0"></option>
<option value="1">Support</option>
<option value="2">Betalning</option>
<option value="3">Övrigt</option>
</select>
<input type="submit" name="btnSend" value="Skicka" />
</form>
</body>
</html>
Asp
Kod:
<%
'get info
firstname = request.form("firstname")
lastname = request.form("lastname")
mailto = request.form("mailto")
'error checking
if len(firstname) < 3 then
isError = true
errorMsg = "Namn <br />"
end if
if len(lastname) < 3 then
isError = true
errorMsg = errorMsg & "Efternamn <br />"
end if
if mailto = "0" then
isError = true
errorMsg = errorMsg & "Ärende <br />"
end if
'write error
if isError = true then
response.Write("<strong>Fyll i</strong><br />")
response.Write(errorMsg)
response.end
else
'fixa body:n hur du vill ha den...
mail_text = mail_text & firstname
mail_text = mail_text & lastname
select case mailto
case 1
strMailTo = "[email protected]"
case 2
strMailTo = "[email protected]"
case 3
strMailTo = "[email protected]"
case else
strMailTo = "[email protected]"
end select
Set JMail = Server.CreateObject("JMail.Message")
JMail.Logging = true
JMail.ISOEncodeHeaders = true
JMail.From = "[email protected]"
JMail.FromName = "Webbsidan"
JMail.Subject = "Web"
JMail.AddRecipient strMailTo
JMail.HTMLBody = mail_text
JMail.MailServerUserName = "[email protected]"
JMail.MailServerPassWord = "lösenord"
JMail.Send("smtp.server.se")
set JMail = nothing
response.Write("<strong>Förfråga mailad.</strong>")
end if
%>