Mail using CDOSYS not working in asp classic application

97 views Asked by At

I have been trying to send email using the CDOSYS object in ASP classic application but neither am I getting an error or email is sending. I am able to see the text "Mail was sent" but the mail is not reaching the destination. Not sure how to debug the issue. The code is as below

            <% 
        If Request.Form("Submit")="Send Email" Then 
        
            Dim objCDO
            Set objCDO = Server.CreateObject("CDO.Message")
            objCDO.Importance = 2
            objCDO.To = "[email protected]"
            objCDO.From ="[email protected]"
            objCDO.Subject = "Test Mail"
            objCDO.TextBody = "This is to test email functionality"
objCDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            Response.write("<i>Mail was Sent</i><p>") 'You should always do this with CDONTS. 
            Set objCDO= Nothing
        %>
        
        <!DOCTYPE html>
        <html>
        <head>
            <title> Send Email </title
        </head>
        <body>
            <form method="post" action="">
                <input type="submit" name="submit" value="Send Email"/>
                </form>
        </body>
        </html>
1

There are 1 answers

2
easleyfixed On

You need to also SEND the email after you are done setting it up. Add this code

objCDO.Send

BEFORE this line:

Response.write("<i>Mail was Sent</i><p>") 'You should always do this with CDONTS.