For some reason, we couldn't directly figure out how to use our normal VBscript that sends emails to send emails using an ExchangeOnline/Office 365 account. We tried all kinds of steps and it didn't work. So we eventually decided to just configure an SMTP service on our server using IIS 6 and then having our VBScript talk to the IIS SMTP service, which then sends the emails via Office 365. Here are the steps: 1) Configure your IIS SMTP service using the steps in this Microsoft kbase article: 2) Configure VBScript code as follows: Dim strBody strBody = "Test email " Dim ObjSendMail Set ObjSendMail = CreateObject("CDO.Message") 'This section provides the configuration information for the remote SMTP server. ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 0 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 NOTE: these next two lines are the windows user id and password that has security permissions to connect to the IIS server: ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "userid" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" ObjSendMail.Configuration.Fields.Update ObjSendMail.To = "someone@email.com" ObjSendMail.Subject = "test email " ObjSendMail.From = "someone@yourorganization.com" ObjSendMail.TextBody = strBody ObjSendMail.Send Set ObjSendMail = Nothing 3) You have to go into the Office 365 admin portal and create a connector for the IP address of the IIS SMTP server. Go to the Exchange Online admin center, then "mail flow" then "connectors". You have to add a rule that allows a connection from your IIS SMTP server. |
VBScripting >