Support

Program Settings How to Send Email When a Scan Completes
Program Settings

Information in this article applies to:

  • uScope Navigator V4.0 and Later

Article ID: NPF1164 — Created: 11 Mar 2018 — Reviewed: 29 Aug 2019

Question

Is it possible to send an email when a scan completes?

Answer

Yes. Several things are required to do this:

  1. You will need a script that can send an email message.
  2. You must, of course, modify the script for your email server, sender, and recipient.
  3. You must add the script to the uScope Navigator workflow.

Creating a Script to Send Email

First, you need a script that sends an email message. The following Windows Script Host File does just that. You must modify the fields listed at the top of the file to specify:

  • Your SMTP server and port.
  • The account user ID and password (if required).
  • The From and To email addresses as well as the Email Subject.

The script is called from within the uScope Navigator application.

  • SendEmail.wsf

'==================================================================================================
'==================================================================================================
Option Explicit

<job>
<script language="VBScript">

Const smtpServer = "smtp.server.com"
Const smtpPort   = 25      ' 25, 465, 587

Const smtpAccount = ""
Const smtpPassword = ""

Const emailFrom    = "From Name <from.me@email.address>"
Const emailTo      = "To Name <to.me@email.address>"
Const emailSubject = "Your Scan has Completed"

'==================================================================================================
'==================================================================================================
Function SendEmail (sJobName)

Dim oMail

Set oMail = CreateObject("CDO.Message")
Set oCfg = oMail.Configuration.Fields


' Use an SMTP server
oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smtpPort
oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

' SMTP authentication
If smtpAccount <> "" Then
  oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
  oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = smtpAccount 
  oCfg.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = smtpPassword
Else
  oCfg.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
End If

oMail.Configuration.Fields.Update


oMail.From = emailFrom
oMail.To   = emailTo
oMail.Subject  = emailSubject


' HTML vs TEXT Email
If (True) Then
  oMail.HTMLbody = "<h1>Your scan (" & sJobName & ") has completed.</h1>" & vbCrLf & vbCrLf & sReport
Else
  oMail.Textbody = "Your scan (" & sJobName & ") has completed." & vbCrLf & vbCrLf & sReport
End If


' Add an email attachment
' oMail.AddAttachment "C:\Folder\Image.JPG"
' oMail.AddAttachment "C:\Folder\File.XML"
' oMail.AddAttachment "C:\Folder\Info.TXT"


' Send the Email Message
oMail.Send


Set oMail=Nothing

End Function

'==================================================================================================
'==================================================================================================
Function main ()

Set colNamedArguments = WScript.Arguments.Named

SendEmail (colNamedArguments.Item("JobName"))

End Function

'==================================================================================================
'==================================================================================================
main()

</script>
</job>

'==================================================================================================
'==================================================================================================

You must copy the above script and paste it into a file on your PC. For illustration purposes, we place all scripts in the C:\Scripts folder. You can double-click on the script to run it. An email should be sent and received.

Note
It is beyond the scope of this knowledge base article to debug email and SMTP problems. For that, you need to contact your company's IT department for assistance.

The script is invoked as follows:

C:\Scripts\SendEmail.wsf "/JobName:%JobName%"

from within the uScope Navigator application at the end of each scan to send an email. Quotes are used to encapsulate arguments that may include spaces (like path names).

  • /JobName:%JobName%
    Specifies the name of the scan job. %JobName% is a macro that is replaced by uScope Navigator with the name of the current job.

Adding the Script to the uScope Navigator Workflow

You can add a script that is run every time a scan is completed or whenever a Deep Zoom image is created.

To send an email when scanning is completed...

  1. Set Post Scan Action Select the Application tab from the Program Options dialog. Here, you can specify commands or scripts that run automatically before and after scanning a region of interest.
  2. Under Post Scan Action, select Command and enter C:\Windows\System32\wscript.exe. This is a Windows command that is required to run Windows Script Host files.
  3. For Parameters, enter "C:\Scripts\sendemail.wsf" "/jobname:%JobName%" as shown.

Now, when you complete scanning a region of interest, the script is automatically run and the email message is sent.

To send an email after creating a deep zoom image...

As an alternative (or addition) to the above, you could automatically create a deep zoom image after each scan completes, then send the email after the deep zoom image is created.

  1. Select the Deep Zoom Options tab from the Program Options dialog. Here, you can specify commands or scripts that run automatically before and after creating a Deep Zoom image.
  2. Under Post Deep Zoom Action, select Command and enter C:\Windows\System32\wscript.exe. This is a Windows command that is required to run Windows Script Host files.
  3. For Parameters, enter "C:\Scripts\sendemail.wsf" "/jobname:%JobName%" as shown.

Now, after a deep zoom image is created, the script is automatically run and the email message is sent.

Related Articles

Rate This Article
Contact Microscopes International or speak with your local distributor.
Copyright © 2025 Microscopes International, LLC. All rights reserved.