Skip to content

Instantly share code, notes, and snippets.

@jovabe
Last active March 19, 2020 00:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jovabe/d37f0cf7879fb48d07a0 to your computer and use it in GitHub Desktop.
Save jovabe/d37f0cf7879fb48d07a0 to your computer and use it in GitHub Desktop.
Pervasive Data Integrator RIFL Scripts
'*** PUBLIC VARIABLES ***
Public logger as DJRowSet
'*** Add log message to reusable rowset and output to pervasive log ***
Public Function logmsg(msg)
IF logger Is Nothing THEN
Set logger = New DJRowSet
END IF
logger.append(msg)
LogMessage("DEBUG","ABSILOG | " & format(now(), "yyyy-mm-dd hh:mm") & " | " & msg)
End Function
'*** Empty the log or initialize if not found ***
Public Function logclear()
IF logger Is Nothing THEN
Set logger = New DJRowSet
ELSE
logger.Clear
END IF
End Function
'*** Output the whole log line by line ***
Public Function logoutput()
Dim output
output = ""
IF NOT logger Is Nothing AND logger.Size > 0 THEN
For i = 1 To logger.Size
output = output & logger.Value(i, 1) & Chr(10)
Next i
ELSE
output = "Log is empty"
END IF
Return output
End Function
'*** PUBLIC VARIABLES ***
Public mailer as DJComponent
Public mail as DJMessage
'*** INIT ***
Private Function InitMailer()
'Set Variables
Set mailer = New DJComponent "SendMail-SMTP"
Set mail = FindMessage("mail")
If mail is Nothing Then
Set mail = New DJMessage("mail")
End If
'Set Properties
mailer.properties("UserName") = ""
mailer.properties("Password") = ""
mailer.properties("Host") = "1.1.1.1"
mailer.properties("Port") = "25"
mailer.properties("RetryCount") = "3"
mailer.properties("ConnectionTimeOut") = "90"
mailer.properties("From") = "do-not-reply@absi.be"
mailer.properties("CharSet") = "ISO-8859-1"
End Function
'*** DEINIT ***
Private Function DeinitMailer()
'Unset variables
Set mailer = Nothing
Set mail = Nothing
End Function
'*** MAIL TO ONE PERSON ***
Public Function SendMailTo(subject, msg, emailAddress)
InitMailer()
'Set subject and body
mailer.properties("Subject") = subject
mail.body = msg
'Set Receiver and send mail
mailer.properties("To") = emailAddress
On Error Resume Next
'Send Mail
mailer.execute(mail)
'Deinit
DeinitMailer()
End Function
'*** MAIL TO MULTIPLE PERSONS ***
Public Function SendMailToList(subject, msg, receiversfile)
InitMailer()
'Set subject and body
mailer.properties("Subject") = subject
mail.body = msg
'Set Receiver and send mail
mailer.properties("To List") = receiversfile
On Error Resume Next
'Send Mail
mailer.execute(mail)
'Deinit
DeinitMailer()
End Function
'*** MAIL TO ONE PERSON WITH ATTACHMENT ***
Public Function SendMailToAttach(subject, msg, emailAddress, attachmsg as DJMessage)
InitMailer()
'Set subject and body
mailer.properties("Subject") = subject
mail.body = msg
'add attachment
mail.addAttachment(attachmsg)
'Set Receiver
mailer.properties("To") = emailAddress
On Error Resume Next
'Send Mail
mailer.execute(mail)
'Deinit
mail.removeAttachment(attachmsg.Name)
DeinitMailer()
End Function
'*** MAIL TO MULTIPLE PERSONS WITH ATTACHMENT ***
Public Function SendMailToListAttach(subject, msg, receiversfile, attachmsg as DJMessage)
InitMailer()
'Set subject and body
mailer.properties("Subject") = subject
mail.body = msg
'add attachment
mail.addAttachment(attachmsg)
'Set Receiver
mailer.properties("To List") = receiversfile
On Error Resume Next
'Send Mail
mailer.execute(mail)
'Deinit
mail.removeAttachment(attachmsg.Name)
DeinitMailer()
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment