After much fiddling around and a lot of guesswork at my Web Host's email settings I have added a Contact me page to the site.
It uses the following simple bit of code:
dim m_strError
dim m_strSuccess
call main()
private sub main()
if IsValid() then
call SendEmail()
end if
end sub
private function IsValid()
Dim bReturn
bReturn = true
if Request("Postback") = "True" then
if Request("Subject") = "" then
bReturn = false
m_strError = "You have not give your message a subject"
end if
if Request("Body") = "" then
bReturn = false
m_strError = "You have not entered your message"
end if
else
bReturn = false
end if
IsValid = bReturn
end function
private sub SendEmail()
Dim objCDOMessage
Set objCDOMessage = Server.CreateObject("CDONTS.NewMail")
' creates the object
objCDOMessage.From = "from@address.com"
objCDOMessage.To = "to@address.com" ' the address listed as "To"
' you could include bcc and cc recipients as well
objCDOMessage.Subject = Request("Subject")
objCDOMessage.Body = "From mailto:" & Request("From") & vbCrLf &vbCrLf & Request("Body")
'now send the message
objCDOMessage.Send
m_strSuccess = "Message Sent"
'wrap things up
Set objCDOMessage = Nothing
end sub