Friday, 10 April 2015

Send an Mail Using CLASSIC ASP (CDOSYS)


Send an Mail Using CLASSIC ASP

Use flowing code in .asp page. Just update required data like email and password.

<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<%
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="smtp.1and1.com"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "xyz@xyz.com" 'Enter YOUR E-MAIL ADDRESS here
objConfig.Fields(cdoSendPassword) = "Passw@rd" 'Enter the PASSWORD for your email address
objConfig.Fields.Update

Set objMail.Configuration = objConfig
objMail.From = "xyz@xyz.com" 'Enter the FROM ADDRESS
objMail.To = "abc@abc.com" 'Enter the TO ADDRESS
objMail.Subject ="Subject" 'Enter a SUBJECT
objMail.TextBody="Mail bODY" 'Enter the BODY of the message
objMail.Send

If Err.Number = 0 Then
Response.Write("Mail sent!")
Else
Response.Write("Error Code: " & Err.Number)
Err.Clear
End If
Set objMail=Nothing
Set objConfig=Nothing
%>