Classic ASP and sending Mails via Office365

CarstenFlorstedt-7205 6 Reputation points
2021-07-09T18:25:29.553+00:00

Hello,
sending emails with Classic ASP to my own Exchange 2016 works without a problem.
(I created a connector to accept mails from the webserver)

Textbody="<h1>1. This is a message.</h1>"
Set objEmail = CreateObject("CDO.Message")
objEmail.To = "to@tiedtlaw email .com"
objEmail.from = "from@tiedtlaw email .com"
objEmail.Subject = "[Tix]: HTML Test Exchange Server"
objEmail.HTMLbody = Textbody
objEmail.Send
Set ojbEmail = NOTHING

Now I found basically this to authenticate and send emails to the Office365 mail server:

Textbody="Sending a text e-mail using a remote server:"
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.To = "to@tiedtlaw email .com"
myMail.from = "from@tiedtlaw email .com"
myMail.TextBody = Textbody
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 ' or 587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email@microsoft.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendtls") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
myMail.Configuration.Fields.Update
myMail.Send
set myMail = nothing

I was using Powershell and was able to authenticate and send an email (see here:
https://answers.microsoft.com/en-us/msoffice/forum/all/using-cdosys-to-send-email-via-smtp/1bf2d068-1f46-4ef3-89af-cdf48cae706a )

But all the tests to send via classic ASP did not work.
I suspect that some TLS or anything like this does not work?

Does it work somewhere?

Windows development | Internet Information Services
{count} vote

1 answer

Sort by: Most helpful
  1. CarstenFlorstedt-7205 6 Reputation points
    2021-07-13T18:41:07.893+00:00

    Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

    2021-07-13 18:26:37 W3SVC5 dcwww xxx.xxx.xxx.xxx GET /mail.asp |26|8004020e|- 80 - xxx.xxx.xxx.xxx Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/91.0.4472.124+Safari/537.36 ASPSESSIONIDQCQBQQTD=HFPJHLBBAPJKDNELHFFFDNHO;+ASPSESSIONIDSSDCTQDD=MEAFBMFBDJJELKALIPLJCNEI;+ASPSESSIONIDCSSRBDSD=MMFNAIOCHGDJKHHMPNFGOJCJ - www.xxxx.com 500 0 0 338 648 5103

    I guess this error means user name or Authentications is wrong.

    I double checked the username and password.
    I also followed the steps to enable AUTHENTICATED SMTP on the O365 account and I also tried to enabled it for all accounts (wiht the Powershell on the O365 account)

    The Event Viewer did not show anything


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.