I'm using emailrelay function to send emails, some days the emails come and others they don't. When it rappens I have my variable EmailSuccess=-3 and the Result = Cannot connect to Konect.
Can I use this function to send a daily email or it's not reliable?
There are customers using successfully using EmailRelay for daily emails.
Perhaps your network connection isn't 100% reliable. You could add some logic in your program to do retries if it fails.
Look, I'm writing a routine to check new files and send it once a day, Each successful email whites in a table with 30 positions.
The program must checks out the last 9 files in URS driver, if one or more files wasn't sent, it sends an email. While I'm testing if it works I did not included any routine to stop the attempts off sending the mails.
I still trying to connect with our smtp corporate server but while it doesn't happen I tried a free smtp server successfully.
As this is not a safe solution, I've treid emailrelay, but, as I said, doesn't work every day.
Below the way I'm trying to do it work:
SlowSequence
Scan(1,sec,1,0)
'Comparar nomes dos arquivos com os anexos enviados e enviar os que nao o foram
For i=1 To FileNames
For j=1 To 30
If Files(1,i) = Table3.LastFileSent(1,j) Then
ExitFor
EndIf
Next j
If j=30 Then
Message = "Este e um arquivo enviado automaticamente do datalogger CR1000 SN" & Status.SerialNumber & CRLF
Message = Message & "Arquivo enviado por " & Status.StationName & ". " & CRLF
Message = Message & "A data e hora de envio sao " & Status.Timestamp & CRLF
Message = Message & "O datalogger se conectou com o IP:"& P3Open
'EmailSuccess=EmailRelay (ToAddr,Subject,Message,Result,Files(1,i))
EmailSuccess=EmailSend (ServerAddr,ToAddr,FromAddr,Subject,Message,Files(1,i),UserName,Password,Result)
If EmailSuccess=-1 Then
LastFileSent=Files(1,i)
CallTable Table3
EndIf
EndIf
Next i
NextScan
With emailsend it works.