Classic ASP Send Email - Full Code

Classic ASP Send Email

<%
' ASP Send Mail Sample.

' In order to run this sample,
' replace the user name 'mail@example.com' with the e-mail of the account used to send the e-mail,
' replace the password 'PASSWORD' with the proper password of the account used to send the e-mail,
' replace the mail FROM address 'mail@example.com' with the e-mail of the account used to send the e-mail,
' and replace the mail TO address 'mail@example.com' with the e-mail address to send to.


' Create CDO.Message COM object.
' http://msdn.microsoft.com/en-us/library/ms527271(v=exchg.10)
Set myMail=CreateObject("CDO.Message")


' Message Configuration.

' Specifies the method used to send messages.
' http://msdn.microsoft.com/en-us/library/ms526994(v=exchg.10)
' http://msdn.microsoft.com/en-us/library/ms527265(v=exchg.10)
' Must be set to 2!
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

' Specifies the authentication mechanism to use when authentication is required to send messages to an SMTP service using a TCP/IP network socket.
' http://msdn.microsoft.com/en-us/library/ms526600(v=exchg.10)
' http://msdn.microsoft.com/en-us/library/ms526961(v=exchg.10)
' Must be set to 1!
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

' The name (DNS) or IP address of the machine hosting the SMTP service through which messages are to be sent.
' http://msdn.microsoft.com/en-us/library/ms527294(v=exchg.10)
' Set to 'localhost' for local SMTP server.
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"

' The port on which the SMTP service specified by the smtpserver field is listening for connections.
' http://msdn.microsoft.com/en-us/library/ms526227(v=exchg.10)
' Set to 25 for local SMTP server.
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25


' Authentication.

' The username for authenticating to an SMTP server using basic (clear-text) authentication.
' http://msdn.microsoft.com/en-us/library/ms527002(v=exchg.10)
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mail@example.com"

' The password used to authenticate to an SMTP server using basic (clear-text) authentication.
' http://msdn.microsoft.com/en-us/library/ms526940(v=exchg.10)
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "PASSWORD"


' Update the configuration fields.
' http://msdn.microsoft.com/en-us/library/jj250294(v=office.15).aspx
myMail.Configuration.Fields.Update


' Set mail FROM.
' http://msdn.microsoft.com/en-us/library/ms527318(v=exchg.10)
' Must match user name used for SMTP authentication!
myMail.From = "mail@example.com"

' Set mail TO.
' http://msdn.microsoft.com/en-us/library/ms527328(v=exchg.10)
myMail.To = "mail@example.com"

' Set mail SUBJECT.
' http://msdn.microsoft.com/en-us/library/ms527248(v=exchg.10)
myMail.Subject = "Sending e-mail with CDO"

' Set mail BODY (HTMLBody).
' http://msdn.microsoft.com/en-us/library/ms527537(v=exchg.10)
' Do not uncomment both, HTMLBody and TextBody, at the same time.
myMail.HTMLBody = "<H3>This is an HTML message.</H3>"

' Set mail BODY (TextBody).
' http://msdn.microsoft.com/en-us/library/ms526935(v=exchg.10)
' Do not uncomment both, HTMLBody and TextBody, at the same time.
'myMail.TextBody = "This is a plain text message."


' Send the mail.
' http://msdn.microsoft.com/en-us/library/ms527781(v=exchg.10)
myMail.Send


' Release CDO object.
set myMail = nothing
%>

<HTML>
<BODY>
  E-mail sent on <%= Now() %>.
</BODY>
</HTML>



Contact us for any question on this topic

Search for any Payment Gateway PayPal, CCAvenue, WorldPay, Technology Help

Click here to Contact for any Integration Help

Earn Rs 51 and Help a Needy and more on further referral (INDIA ONLY) I’m inviting you to join Tez, a simple and secure payments app by Google. Here’s my code UG0W9 - just enter it before your first transaction. Once you’ve sent your first payment, we’ll each get ₹51! https://g.co/tez/UG0W9