Sending an email via SMTP with VBScript: Difference between revisions

From Starfish ETL
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang="visualbasic"> Sub VBScriptProcedure Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "TEST SUBJECT!" objMessage.From = "trevor.walker@techadv.com" objMessage.To = "justin.kuehlthau@techadv.com" objMessage.TextBody = "Test Body" Set objConfig = objMessage.Configuration objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objConfig.Fields("http://schemas.microsoft.com/c...")
(No difference)

Revision as of 20:20, 11 July 2024

<syntaxhighlight lang="visualbasic"> Sub VBScriptProcedure

   Set objMessage = CreateObject("CDO.Message") 
   objMessage.Subject = "TEST SUBJECT!" 
   objMessage.From = "trevor.walker@techadv.com" 
   objMessage.To = "justin.kuehlthau@techadv.com" 
   objMessage.TextBody = "Test Body"
   Set objConfig = objMessage.Configuration
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sandbox.smtp.mailtrap.io"
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "8bff8a885fa97c"
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "630b8fef12e981"
   'Server port (typically 25)
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
   objConfig.Fields.Update
   objMessage.Send

End Sub </syntaxhightlight>