Sending an email via SMTP with VBScript: Difference between revisions
Jump to navigation
Jump to search
Jkuehlthau (talk | contribs) No edit summary |
Jkuehlthau (talk | contribs) No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
Set objMessage = CreateObject("CDO.Message") | Set objMessage = CreateObject("CDO.Message") | ||
objMessage.Subject = "TEST SUBJECT!" | objMessage.Subject = "TEST SUBJECT!" | ||
objMessage.From = " | objMessage.From = "from@email.com" | ||
objMessage.To = " | objMessage.To = "to@email.com" | ||
objMessage.TextBody = "Test Body" | objMessage.TextBody = "Test Body" | ||
Set objConfig = objMessage.Configuration | Set objConfig = objMessage.Configuration | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = " | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com" | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = " | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username" | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = " | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" | ||
'Server port (typically 25) | 'Server port (typically 25) | ||
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 | objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 | ||
Latest revision as of 20:25, 11 July 2024
Sub VBScriptProcedure
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "TEST SUBJECT!"
objMessage.From = "from@email.com"
objMessage.To = "to@email.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") = "smtp.server.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
'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