SMTP Email weirdness
Don DeLong
Posts: 43
I have a Netlinx system that, among other functions, serves as a master monitor for several interconnected paging systems, each of which have their own Netlinx master connected via M2M, and recently added email functionality that sends status updates to a list of addresses stored in an array. The message format is simple, listing the time & date the master sent the message, then text describing the status of each system on the network, followed by a bit of text explaining why the email was sent (system showing alarm, warning, status change, or user interaction).
This is triggered by a timeline that fires every 6 hours, plus any time status changes of one of the systems, or when an admin manually sends a test email from a virtual TP.
Everything works OK, except at the end of each email, there is sometimes a bunch of random junk appended, which looks like part of a previous email. I can't nail down why this would happen, as the message is assembled in a STACK_VAR inside the function that sends the email.
Has anyone had any experience with this? Master is running FW v4.1.373, code for email functionality is below:
Thanks,
Don
This is triggered by a timeline that fires every 6 hours, plus any time status changes of one of the systems, or when an admin manually sends a test email from a virtual TP.
Everything works OK, except at the end of each email, there is sometimes a bunch of random junk appended, which looks like part of a previous email. I can't nail down why this would happen, as the message is assembled in a STACK_VAR inside the function that sends the email.
Has anyone had any experience with this? Master is running FW v4.1.373, code for email functionality is below:
DEFINE_FUNCTION fnSEND_EMAIL_STATUS(CHAR sTEXT_TO_APPEND[64]) { STACK_VAR INTEGER nSYSTEM_NUMBER STACK_VAR INTEGER nALARM_LEVEL STACK_VAR INTEGER nPROBLEM_SYSTEM STACK_VAR INTEGER nADDRESS_LOOP_COUNTER STACK_VAR CHAR sEMAIL_TEXT[1024] STACK_VAR CHAR sEMAIL_SUBJECT[64] IF(nENABLE_EMAIL) { sEMAIL_TEXT = " 'Corporate PA Monitor Status Report',$0D,$0A,$0D,$0A, //START OF MESSAGE DATE,' ',TIME,$0D,$0A,$0D,$0A //MASTER'S DATE & TIME " nALARM_LEVEL = STATUS_OK //CLEAR nALARM_LEVEL IF(nPANEL_ONLINE[1] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'COMMAND CENTER TP OFFLINE',$0D,$0A" } IF(nPANEL_ONLINE[2] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'BB-28 TP OFFLINE',$0D,$0A" } IF(nPANEL_ONLINE[3] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'SA-1 SECURITY TP OFFLINE',$0D,$0A" } IF(nPANEL_ONLINE[4] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'C-1 TP OFFLINE',$0D,$0A" } IF(nPANEL_ONLINE[5] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'SA-1 VISITOR TP OFFLINE',$0D,$0A" } IF(nPANEL_ONLINE[6] == FALSE) //IF PANEL IS OFFLINE { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING } sEMAIL_TEXT = "sEMAIL_TEXT, 'SA-4 VIRTUAL TP OFFLINE',$0D,$0A" } sEMAIL_TEXT = "sEMAIL_TEXT, $0D,$0A,$0D,$0A" FOR(nSYSTEM_NUMBER = 1;nSYSTEM_NUMBER <= 27;nSYSTEM_NUMBER++) { IF(AUDIO_SYSTEM_ARRAY[nSYSTEM_NUMBER].dvDEVICE.SYSTEM) //IF DEVICE IS DEFINED { sEMAIL_TEXT = "sEMAIL_TEXT,AUDIO_SYSTEM_ARRAY[nSYSTEM_NUMBER].sSYSTEM_NAME,': '" //APPEND SYSTEM NAME, COLON, SPACES TO TEXT SWITCH(AUDIO_SYSTEM_ARRAY[nSYSTEM_NUMBER].nSYSTEM_STATUS) { CASE STATUS_OK: { sEMAIL_TEXT = "sEMAIL_TEXT,'SYSTEM OK',$0D,$0A" } CASE STATUS_WARNING: { IF(nALARM_LEVEL < STATUS_ALARM) { nALARM_LEVEL = STATUS_WARNING nPROBLEM_SYSTEM = nSYSTEM_NUMBER } sEMAIL_TEXT = "sEMAIL_TEXT,sSYSTEM_LAST_ERROR[nSYSTEM_NUMBER],$0D,$0A" //APPEND LAST ERROR (CURRENT ERROR) } CASE STATUS_ALARM: { IF(nALARM_LEVEL = STATUS_ALARM) { nPROBLEM_SYSTEM = SYS_MULTIPLE } ELSE { nPROBLEM_SYSTEM = nSYSTEM_NUMBER } nALARM_LEVEL = STATUS_ALARM sEMAIL_TEXT = "sEMAIL_TEXT,sSYSTEM_LAST_ERROR[nSYSTEM_NUMBER],$0D,$0A" //APPEND LAST ERROR (CURRENT ERROR) } } } } sEMAIL_TEXT = "sEMAIL_TEXT,sTEXT_TO_APPEND" //APPEND TEXT PASSED TO FUNCTION TO END OF REPORT SWITCH(nALARM_LEVEL) { CASE STATUS_OK: { sEMAIL_SUBJECT = "'Corporate PA Monitor Status Report: ALL SYSTEMS OK'" } CASE STATUS_WARNING: { sEMAIL_SUBJECT = "'Corporate PA Monitor Status Report: WARNING-',AUDIO_SYSTEM_ARRAY[nPROBLEM_SYSTEM].sSYSTEM_NAME" } CASE STATUS_ALARM: { IF(nPROBLEM_SYSTEM == SYS_MULTIPLE) { sEMAIL_SUBJECT = "'Corporate PA Monitor Status Report: ALARM-MULTIPLE SYSTEMS'" } ELSE { sEMAIL_SUBJECT = "'Corporate PA Monitor Status Report: ALARM-',AUDIO_SYSTEM_ARRAY[nPROBLEM_SYSTEM].sSYSTEM_NAME" } } } FOR(nADDRESS_LOOP_COUNTER = 1;nADDRESS_LOOP_COUNTER <= 20;nADDRESS_LOOP_COUNTER++) { IF(sEMAIL_ADDRESS_LIST[nADDRESS_LOOP_COUNTER]) //IF AN ADDRESS EXISTS { SMTP_SEND(dvMAIL_HANDLER,sEMAIL_ADDRESS_LIST[nADDRESS_LOOP_COUNTER],sEMAIL_SUBJECT,sEMAIL_TEXT,NULL_STR) IF(nDEBUG) { SEND_STRING 0, "'SENDING EMAIL TO: ',sEMAIL_ADDRESS_LIST[nADDRESS_LOOP_COUNTER]" } } } IF(nDEBUG) { SEND_STRING 0, "'EMAIL SUBJECT: ',sEMAIL_SUBJECT" SEND_STRING 0, "'EMAIL BODY: ',sEMAIL_TEXT" } } }
Thanks,
Don
0
Comments