Hi,
I'm wondering if there's a specific issue with using EmailSend within a for/next loop (for multiple email contacts in an array).
For some reason this code appeared to complete properly, i.e. it sent the emails, reset the rainfall total to zero.
But it didn't send the SMS's, and proceeded to send hundreds of emails but only to the second Email_Contact. The ServerResponse constantly showed "Ready to start TLS", and appeared to send a new email every 5 minutes with various other strings showing in ServerResponse momentarily, before reverting backt o "Ready to start TLS".
When the email settings weren't yet set up, the for/next for the SMS array worked fine.
(The second email recipient had an active out of office reply, but I wouldn't imagine that would have impacted)
If Rain6amSend > 0 Then
'Construct message
message = "Station " + GSNumber + ". 24hr to 6am: " + Rain6amSend + "mm"
'Send Email
For i = 1 To 2
EmailSend(EMAIL_SVR,Email_Contact(i),EMAIL_FROM,"Daily Rainfall",message,EMAIL_ATT,EMAIL_USR,EMAIL_PASS,EmailResp)
Next i
'Send SMSes
For i = 1 To 2
Call BGAN_SMSSend(SMS_PhNo(i),message)
Next i
Rain6amSend = 0
EndIf
When I removed the for/next loop and just replaced the code with as below, everything worked fine, it sent the emails, then the SMS, when complete, ServerRespose showed it's usual "bye" message.
If Rain6amSend > 0 Then
'Construct message
message = "Station " + GSNumber + ". 24hr to 6am: " + Rain6amSend + "mm"
'Send Email
EmailSend(EMAIL_SVR,Email_Contact(1),EMAIL_FROM,"Daily Rainfall",message,EMAIL_ATT,EMAIL_USR,EMAIL_PASS,EmailResp)
EmailSend(EMAIL_SVR,Email_Contact(2),EMAIL_FROM,"Daily Rainfall",message,EMAIL_ATT,EMAIL_USR,EMAIL_PASS,EmailResp)
'Send SMSes
Call BGAN_SMSSend(SMS_PhNo(1),message)
Call BGAN_SMSSend(SMS_PhNo(2),message)
Rain6amSend = 0
EndIf