×
Menu
Index

3.6.5.1. Send Email on Error (OnProcessFinish)

 
This sample will send an email and should be placed on the OnProcesFinish step of the Hotfolder workflow. If there are any validation errors on the current Batch the email will be sent out.
The same kind of code can be used for sending out emails right after document processing by using the Execute VBScript option instead of the HotFolder mode option on the Tasks & Process Menu on the Document Document Toolbar on the Scan/Input Tab.
 
 
 
To execute the code using hotfolders select the HotFolder option for the VBScript.
 
 
 
Set Batch = ChronoApp.GetCurrentBatch
 
BatchName=Batch.GetName
NumDocs=Batch.GetDocCount
 
'This bit of code will return the number of documents with errors on the current Batch
 
NumErrors=Batch.GetDocCountStatus(1)
 
'A condition is created for the number of errors on the current Batch
 
If NumErrors >0 Then
 
'The code for the email is the following. Several details can be added including attachments
 
    strSMTPFrom = "TOemail@domain.com"
    strSMTPTo = "FROMemail@somedomain.com"
    strSMTPRelay = "yourrelay.domain.net"
    strTextBody = ""
    strSubject = BatchName & " has " & NumErrors & " validation error(s)"
 
    'A good idea is to include a file with the export report as an attachment
 
    strAttachment = "c:\this_attachment.pdf"
 
 
    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
 
    oMessage.Subject = strSubject
    oMessage.From = strSMTPFrom
    oMessage.To = strSMTPTo
    oMessage.TextBody = strTextBody
    'oMessage.AddAttachment strAttachment
 
 
    oMessage.Send
 
Else
End If
 
NOTE: This code can also be used on other parts of ChronoScan.