Sample code --Use CDO to send email through Office 365

Programming, error messages and sample code > sample code
This is just quick sample code to get you on the right path:
 
<%
Set objMessage = CreateObject("CDO.Message")
objMessage.From = "Your Office365 email account"
objMessage.To = "The recipient address"
objMessage.Subject = "Test email from ASP CDO with Office 365 account"
objMessage.TextBody = "This is a test email."

' Set SMTP server and port for Office 365
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

' Enable TLS 1.2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

' Set Office 365 email account credentials
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Your Office365 email account"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Your email account password"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Update

' Send email
objMessage.Send
Set objMessage = Nothing
%>