Email Via Classic ASP

I know it has been a while since I sat down and wrote a decent post so tonight I figured let me discuss sending emails Classic ASP style. View the code below which will be explained in further detail:

<%
Dim strMailTo
Dim strMailSubject
Dim strMailBody
Dim objCDOMail ‘The CDO object

strMailSubject = “Test Via ASP”

strMailTo = Request.Form(”sendemail”)

strMailBody = “Hello World,”
strMailBody = strMailBody & “This is my first email.”
strMailBody = strMailBody & “Sent via ASP!!!”

Set objCDOMail = Server.CreateObject(”CDO.Message”)

objCDOMail.From = “mail@yourdomain.com”
objCDOMail.To = strMailTo
‘objCDOMail.Cc = “user@domain.com”
‘objCDOMail.Bcc = “user@domain.com”
objCDOMail.Subject = strMailSubject
objCDOMail.TextBody = strMailBody
objCDOMail.Send()
Set objCDOMail = Nothing
%>

Alright so the code above may looked complicated but it really isn’t. Basically the main part of this is the objCDOMail this is telling the server that you want to send a message via email. The variables dimed are just place holders for the objCDOMail parameters for example: strMailSubject is used to hold a string message for the subject line, objCDOMail.Subject.

Comments are closed.