DIAdem is a great tool for reporting locally. This class can help extend this by allow you to add email capabilities to your scripts.
This is achieved by loading a CDO.Message ActiveX class which is provided by windows. In general this class can be used for a number of different message types but we set it up for SMTP to an external server.
Implementation Notes
'-------------------------------------------------------------------------------
'-- VBS Script for Sending Email from DIAdem
'-- Created on 09/07/2013 09:38:26
'-- Author: James McNally, NI UK
'-- Comment: Mostly just a wrapper for CDO Objects. Fully wrapped for future flexibility.
'-------------------------------------------------------------------------------
Option Explicit 'Forces the explicit declaration of all the variables in a script.
'Type library elements that we cannot load into VBS.
'Keeps the code below more readable.
private const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
private const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
private const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
private const cdoSendUsingPort = 2
Class Email
private m_cdoMsg
'Public properties
public From, SendTo, Subject, TextBody, HTMLBody, SendCC, SendBCC, SMTPServer, SMTPPort
private sub Class_Initialize
'CDO.Message documentation at http://msdn.microsoft.com/en-us/library/ms526453(v=exchg.10).aspx
set m_cdoMsg = createobject("CDO.Message")
End Sub
Public Sub AddAttachment(filepath)
m_cdoMsg.AddAttachment(filepath)
End Sub
Public Sub Send
'Check configuration for missing required elements
if (isEmpty(SMTPServer) or isEmpty(SendTo) or isEmpty(From)) then
Call Err.Raise(5000,"Email.Send","You must specify an SMTP server, To and From.")
end if
'Handle a default port if not set.
if isEmpty(SMTPPort) then
SMTPPort = 25
end if
With m_cdoMsg
.From = From
.To = SendTo
.Subject = Subject
.Textbody = TextBody
.HTMLBody = HTMLBody
.CC = SendCC
.BCC = SendBCC
End With
With m_cdoMsg.Configuration.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = SMTPServer
.Item(cdoSMTPServerPort) = SMTPPort
.Update
End With
m_cdoMsg.Send
End Sub
End Class
Software
The 64-bit version of DIAdem 2017 has an object-oriented script interface for sending emails. Details can be found in this topic and also in the related links: http://zone.ni.com/reference/en-XX/help/370858N-01/emailservice/objects/iemailservice_objects_overvi...
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.