Overview
This script will allow you to have email capabilities within DIAdem
Description
I had been trying to use the script at the following location to email from DIAdem-
https://forums.ni.com/t5/Example-Program-Drafts/Send-an-Email-From-DIAdem/ta-p/3525692
However I have been having some problems with it, I believe specifically the CDO ActiveX parts. This script is a bit simpler, and is working well so far, and therefore I thought it might be useful for other people to see it. This script is an edited version of an example I was sent.
'-- VBS script for Sending Email from DIAdem
'-- Created on 04/03/2017 15:34:04
'-- Author: Sarah Corsham, NI UK
'-- Comment:
'-------------------------------------------------------------------------------
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Call SendEmail
'-------------------------------------------------------------------------------------
'-------------------------------------Send Email--------------------------------------
'-------------------------------------------------------------------------------------
Public Function SendEmail()
Dim objOutl, olMailItem, objMailItem, strEmailAddr
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'comment the next line if you do not want to see the outlook window
objMailItem.Display
strEmailAddr = 'Insert email address to be sent from
objMailItem.Recipients.Add 'Insert email address to be sent to
objMailItem.Body = "Hi" 'Text to include in the email
objMailItem.Attachments.Add (CurrentScriptPath & "Test Results.pdf") 'Comment this out if you are not sending an attachement
objMailItem.Subject = "Test" 'Subject line of the email
objMailItem.Send
Set objMailItem = nothing
Set objOutl = nothing
End Function
Hardware and Software Requirements
This currently only works with Outlook- you must have Outlook installed on the computer you run the script on
Steps to Implement or Execute Code
1. Put in required email addresses as shown in comments, and then run the script