asklijo.com

  • Increase font size
  • Default font size
  • Decrease font size
Home Domain Registration

How to send the mail through CDO ( ASP ) with SMTP authentication

In your control panel you can create one email id. So that you can use this email id and its password in your asp code to send the mail. Host address will be your mail.yourdomain. You can use the following code to send your email from your asp script with CDO.

 

Please use the following function to send the mail.

Note * mail.yourdomain has to be replaced by your real domain
id and pwd will be your email id and its password.

 

 

sub sendmail(sTo,Cc,sFrom,sSubject,sBody,id,pwd)
    Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
    Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

    Const cdoAnonymous = 0 'Do not authenticate
    Const cdoBasic = 1 'basic (clear-text) authentication
    Const cdoNTLM = 2 'NTLM

    Set objMessage = Server.CreateObject("CDO.Message")
    objMessage.Subject = sSubject
    'objMessage.Sender = sFrom
    objMessage.From = sFrom

    objMessage.To = sTo
    if Cc"NA" then
        objMessage.Cc=Cc
    end if
    objMessage.HTMLBody = sBody

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.yourdomain"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = id

'Your password on the SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = pwd

'Server port (typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update
objMessage.Send

End sub

 

By
Lijo Peter

Support Desk

Adsin Technologies, Bangalore