MGBlog
Sunday, 19 October 2003
Sun, 19 Oct 2003 - 11:36pm (GMT+1)
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
Comments
Re: CDO Contact Me
Apparenty Microsoft don't supply CDONTS with Windows 2003 Server. Their recomendation is to upgrade applications using it to use CDOSYS or .Net's "System.Web.Mail" namespace.
See Microsoft Knoledge Base article 315197 for more info.
http://support.microsoft.com/default.aspx?scid=kb;en-us;315197
Add Your Comment