email web page using cdonts

1 replies
i have been trying to set something up where i can send the url in an email using cdonts, i wrote this script as a test and it worked, but is it safe?

<%
dim send
send = request("send")
If send = "yes" then
Set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "GET", "somewebsite", false
objHTTP.Send
'Response.Write objHTTP.ResponseText

'send mail
Dim strHTML
strHTML = "<html><head><title>" & request.servervariables("server_name") & "</title></head>"
strHTML = strHTML & objHTTP.ResponseText
strHTML = strHTML & "<a href=""somewebpage"">Remove Me</a>"
strHTML = strHTML & "</body></html>"

'Set up the email object
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
With objMail
.from = "from_email"
.To = "to_email"
.Subject = "Web Development"
.BodyFormat = 0 'CdoBodyFormatHTML
.MailFormat = 0 'CdoMailFormatMime
.Body = strHTML
.Send


End With
Set objMail = Nothing

Response.write "<a href=""cdonts.asp"">Sent</a>"
else
response.write "<a href=""cdonts.asp?send=yes"">Send Mail</a>"
end if
%>
#cdonts #email #page #web
  • Profile picture of the author Adaptive
    Hi Kristian,

    You should mention in your headline that you have a question about classic ASP code in VBScript. The forum includes discussion of several different programming technologies.

    I wrote classic ASP in VBScript back in the day.

    My question is, why are you still doing that? ASP.Net has been available for 7 years now and is so astoundingly better in every way, except the initial learning curve. Why do anything with clunky old technology with such limited functionality, when a far superior alternative is coming up on a decade of proven and even-growing excellence?

    Anyway, if you want to get the Edsel up to highway speed, it would be a good idea to have a function that evaluates the ResponseText - otherwise you are letting another server put arbitrary text onto your page. And it would also be nice to give the user a "mail send in progress" line that will be replaced with "mail sent" or "mail send failure."

    But why, why, why keep driving the Edsel?

    Regards,
    Allen
    Signature

    Success only requires four words. http://www.warriorforum.com/blogs/ad...our-words.html

    {{ DiscussionBoard.errors[674696].message }}

Trending Topics