SendEmailExt

Hi,
I am using Eaton Visual Designer to send email whenever there is a fault. I am using the function SendEmailExt(). An excerpt of the code used is shown below:

Sub InverterFaultSendEvent()
Dim n
For n=1 To $NumberInvertersConfigured
If $Inverter.LastFault <> $InverterTemp1 Then
$FaultAlarmInverter = 1
Select Case $Inverter.LastFault
Case 1
$SendEvent("Inverter "+$Str(n)+" Fault: CURR LOSS1")
$SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: CURR LOSS1" ,"purnaanshg@gmail.com")
Case 2
$SendEvent("Inverter "+$Str(n)+" Fault: EXT FAULT")
$SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: EXT FAULT" ,"purnaanshg@gmail.com")
Case 3
$SendEvent("Inverter "+$Str(n)+" Fault: OUT OVRLD")
$SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OUT OVRLD" ,"purnaanshg@gmail.com")
Case 4
$SendEvent("Inverter "+$Str(n)+" Fault: OVERTEMP")
$SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OVERTEMP" ,"purnaanshg@gmail.com")
Case 5
$SendEvent("Inverter "+$Str(n)+" Fault: OVERCURR")
$SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OVERCURR" ,purnaanshg@gmail.com)
End Select
$InverterTemp1 = $Inverter.LastFault
Else
$FaultAlarmInverter = 0
End If

This procedure send an email whenever a fault is generated but when faults are generated for multiple inverters (multiple values of n) at the "same time" the email is sent only for the first registered fault. All other faults are neglected by the system.

The procedure is working good for one fault at a time but does not execute efficiently for multiple faults at a time.

I suspect there is an issue with the execution of the function SendEmailExt() but don't know what could it be? Is it the method in which the function is executed or something else?

Thanks
  • The correct code in the post is:

    Sub InverterFaultSendEvent()
    Dim n
    For n=1 To $NumberInvertersConfigured
    If $Inverter.LastFault <> $InverterTemp1 Then
    $FaultAlarmInverter = 1
    Select Case $Inverter.LastFault
    Case 1
    $SendEvent("Inverter "+$Str(n)+" Fault: CURR LOSS1")
    $SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: CURR LOSS1" ,"purnaanshg@gmail.com")
    Case 2
    $SendEvent("Inverter "+$Str(n)+" Fault: EXT FAULT")
    $SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: EXT FAULT" ,"purnaanshg@gmail.com")
    Case 3
    $SendEvent("Inverter "+$Str(n)+" Fault: OUT OVRLD")
    $SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OUT OVRLD" ,"purnaanshg@gmail.com")
    Case 4
    $SendEvent("Inverter "+$Str(n)+" Fault: OVERTEMP")
    $SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OVERTEMP" ,"purnaanshg@gmail.com")
    Case 5
    $SendEvent("Inverter "+$Str(n)+" Fault: OVERCURR")
    $SendEmailExt("Inverter Fault", $Date + $Time + "Inverter "+$Str(n)+" Fault: OVERCURR" ,purnaanshg@gmail.com)
    End Select
    $InverterTemp1 = $Inverter.LastFault
    Else
    $FaultAlarmInverter = 0
    End If
    Next
    End Sub
  • Hi.

    I expect all of the Events are being registered, as SendEvent() is described as a synchronous function.

    If the alarms you are describing are essentially simultaneous, I suspect the subsequent emails are not sent due to the first not yet being completed.

    SendEmailExt() is asynchronous and returns a value of 1 if the previous email has not yet been sent. If you don't act on this return value, I expect the email will not be sent.

    Have you tried using the synchronous SendEmail() function? If truly synchronous it should send all messages. However, you will need to be careful with scheduling of the code. In case of other issues which could slow up sending of mail, you can't afford to have it executing in time critical code. There are ways of managing this within Indusoft.

    Regards,
    Greg Shearer
  • Greg is correct, the asynchronous mail send is misleading. Microsoft requires that the next message not be sent until the first has completed. Check for the completed flag before sending the next email and they will all go out.
  • Greg and Mike,

    I agree with careful usage of the SendEmailExt() function because of its asynchronous nature along with the SendEvent() function which is synchronous in nature.

    I was however able to write a VBScript to send automatic emails for every fault caused.

    Thanks for the help.