Send Email in Classic ASP

Use the below code to send the email form classic ASP, you have to change the to and from address. You can also select either you want to send email in HTML format at or in simple textual.

email="toEmailAddress@mail.com"

   Set ObjSendMail = Server.CreateObject("CDO.Message")
            Set iConf = CreateObject("CDO.Configuration")
            Set Flds = iConf.Fields
                
            Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
                
            '**** Path below may need to be changed if it is not correct
            Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
            Flds.Update
                
            Set ObjSendMail.Configuration = iConf
            ObjSendMail.To = email
            ObjSendMail.Subject = txtSubject
            ObjSendMail.From = "info@infoa2z.com"
                
            ' we are sending a text email.. simply switch the comments around to send an html email instead
            'ObjSendMail.HTMLBody = "this is the test email from infoA2Z.com"
            ObjSendMail.TextBody = txtBody
            if(len(email)>0) then
               ObjSendMail.Send
            end if
            email=""
            set ObjSendMail=nothing                                       

Related Alrticles

FREE!!! Registration