0

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 = "as18831@ncr.com"
            objCDO.From ="as18831@ncr.com"
            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>
  • have you tried my answer yet? – easleyfixed Jul 07 '23 at 15:08
  • It has been a week since I answered, I'm curious if you tried this yet, it should work. – easleyfixed Jul 14 '23 at 13:41
  • I was using objCDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2, but seems some backend gateway version has been updated and the emails have stopped. – Ananya Sharma Jul 17 '23 at 13:08
  • Ok but your code doesn't have the send mail command, is it in there and just not posted? But yeah something changed the config probably has to reflect that. – easleyfixed Jul 17 '23 at 13:15

1 Answers1

0

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. 
easleyfixed
  • 219
  • 1
  • 13
  • Wait a minute .. where is the END IF? If there is no END IF .. it should of thrown an error when you ran it .. maybe you didn't include it ? But it needs to be right after this line : Set objCDO= Nothing – easleyfixed Jul 05 '23 at 18:03