Saturday, March 7, 2015

OnBase VB Script to send an email

The following is a sample OnBase VB Script to use to send an email.

Sub Main35()

Const CONNECTSTRING = "DSN=OnBase;UID=<ownerID>;PWD=<ownerPSWD>"

' Root level OnBase Automation object
  Dim oApp
  Set oApp = CreateObject("OnBase.Application")


   oApp.ExecutionStatus = 1

'set up parameters for CDO
strSMTPFrom = "support@yourcompany.com"
strSMTPTo = "level1support@yourcompany.com"
strSMTPRelay = "smtp.yourcompany.com"
strTextBody = "There are too many errors on the server"
strSubject = "ALERT: check OnBase processor server"
strAttachment = ""

'Create and set up CDO object
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
oMessage.Configuration.Fields.Update

'send message
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
'oMessage.AddAttachment strAttachment
oMessage.Send

Set oMessage = Nothing


End Sub 'Main35()

No comments:

Post a Comment