email using office365 account, asp page

Job ID: 35542188

Budget: ₹1,500 – ₹12,500 INR

I need a simple script that will post an email to an Office365 account via a classic asp page. If you need to use something else, please specify what/how you get it to work.



I have been using a script using CDO, but it seems that it's deprecated; sample script below will work when sending an email using my self-hosted email server, but if I use an Office365 email, it will not work. Should be pretty straight forward and simple, but I don't have time to mess with this anymore so putting it out for reasonable bid. I'm aware this is a very small job, and code is certainly already out there for this simple function.



Three variables change in code below:

DESTINATION_EMAIL_HERE

OFFICE365_EMAIL_HERE

OFFICE365_PASSWORD_HERE



<%

Textbody="Sending a text e-mail using a remote server:"

Set myMail = CreateObject("CDO.Message")

myMail.Subject = "Sending email test using script"

myMail.To = "DESTINATION_EMAIL_HERE"

myMail.from = "OFFICE365_EMAIL_HERE"

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") = 587

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "OFFICE365_EMAIL_HERE"

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "OFFICE365_PASSWORD_HERE"

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

%>