Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

Send an Email from DIAdem


This script will allow you to have email capabilities within DIAdem


I had been trying to use the script at the following location to email from DIAdem-



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
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
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

Additional Information or References

Tested on DIAdem 2015 SP2


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...