01-09-2012 09:14 PM
I have an interesting issue that I can't find a solution for. I am using the DIAdem Run Script.VI in Labview to call a script that opens an Outlook object and sends an email. When the script is called via LabView I get this error:
However, when I manually run the script from the DIAdem script tab it works as expected with no errors.
This is the code:
'Begin email send function Dim oOutlookApp Dim oOutlookMail Dim cnByValue : cnByValue = 1 Dim cnMailItem : cnMailItem = 0 ' Get Outlook Application Object Set oOutlookApp = CreateObject("Outlook.Application") ' Create Mail Item Set oOutlookMail = oOutlookApp.CreateItem(cnMailItem) ' Set Mail Values With oOutlookMail .To = "name@company.net" .Subject = "Report: " & Data.Root.ActiveChannelGroup.Name & " for " & CurrDate .Body = "test automatic report emailing with VB Script." ' Add Attachement Call .Attachments.Add(strLocFileName, cnByValue, 1 ) ' Send Mail Call .Send() End With
(Original code includes Option Explicit and all variables are properly included/declared, I just took the snippet of what's causing the error).
I have looked at the following threads for info already:
-I tried running the script via Windows explorer (per Brad's suggestion) by itself without the DIAdem specific functions and it runs fine.
-I am not running the scripts asynchronously
Using Windows 7 (64bit), DIAdem 11.2 and LabView 7.1.1
Thank you.
01-10-2012 01:20 PM
I found the issue, for some reason when Outlook is already open the script will NOT run correctly when called from the Labview VI but when it is called from the DIAdem script editor everything works fine even if Outlook is open. Maybe someone can shed some light on this? Has something do with creating an object that already exists?
01-11-2012 12:06 PM
Hey techerdone -
I'm afraid I personally can't be of much help - I tested your code both from DIAdem and from LabVIEW and each worked without issues in both cases (Outlook closed, Outlook open). I'm using DIAdem 2011 SP1, LabVIEW 2011, and Outlook 2007...
01-11-2012 01:51 PM
Are you on a 32bit or 64bit machine?
01-12-2012 09:43 AM
Hey techerdone - I am also running a 64-bit version of Windows 7.