Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Daily email with new data


Carlos32 Oct 28, 2015 02:34 PM

Hello,

First of all sorry for my english, it is not my first language.
I´m working with CR1000 and trying to create a program who send everyday at 00:00 a email with attached table file to a specific email address. The attached file must contain just the new data from the previous successfully email sent.
Please, could you provide to me an example how to do this.


Thanks,
Carlos.


jra Oct 28, 2015 02:55 PM

Take a look at the Example in the Help for the TableFile() instruction. This video https://www.campbellsci.com/videos?video=42 goes through the features of the CRBasic Help system.


JDavis Oct 28, 2015 08:13 PM

The optional parameters added to the EmailSend instruction in OS28 simplifies things some.

Download OS28 from the website. When you run the .exe file on your computer, it will update the help files in CRBasic editor.

https://www.campbellsci.com/cr1000-support


Carlos32 Oct 29, 2015 07:04 PM

Thank you for the answers.
you can find bellow the last version of the program i did.
Now the datalogger can create one file daily and send the last file created by email at 00:00:00.

But i would like the program do two more things:

1) I want the daily file send by email contents data from 00:00:01 to 00:00:00.

2)If there is a problem to send the email i want the program attempt 3 more times every 20 minutes and if the problem continue wait until next day at 00:00 and then send the pending email and the email with the data of the current day.

Any idea how to do this, thank you very much


StationName POLITRON

Public BattV 'Medicion de Voltaje de alimentacion
Public rTime(9) 'declare as public and dimension rTime to 9
Public OutStat As Boolean
Public LastFile As String * 50
Public EmailResult As String * 50
Public EmailSuccess

Const ServerAddr=""
Const ToAddr=""
Const FromAddr=""
Const Subject="Esto rula weyyy!!"
Const Message= "como andas lo"
Const UserName=""
Const Password=""

Alias rTime(1) = Year 'assign the alias Year to rTime(1)
Alias rTime(2) = Month 'assign the alias Month to rTime(2)
Alias rTime(3) = DOM 'assign the alias DOM to rTime(3)
Alias rTime(4) = Hour 'assign the alias Hour to rTime(4)
Alias rTime(5) = Minute 'assign the alias Minute to rTime(5)
Alias rTime(6) = Second 'assign the alias Second to rTime(6)
Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7)
Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8)
Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9)

Units BattV=Volts

DataTable(Diez_minutal,True,-1) 'Tabla con calculos 10-minutales
DataInterval(0,10,Min,10)
TableFile ("USR:Diez_Minutal",8,-1,0,24,hr,OutStat,LastFile)
Minimum(1,BattV,FP2,False,False)
EndTable

BeginProg
SetStatus ("USRDriveSize",50000)
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
CallTable(Diez_minutal)
NextScan

SlowSequence
Scan (1,Sec,3,0)
RealTime( rTime )
If rTime(4)=0 AND rTime(5)=0 AND rTime(6) = 0 Then
EmailSuccess=EmailSend(ServerAddr,ToAddr,FromAddr,Subject,Message,LastFile,UserName,Password,EmailResult)
EndIf
NextScan
EndProg


JDavis Oct 29, 2015 08:19 PM

In answer to question 1, your file is already set for the time interval you want. Using RealTime within a Slow Sequence is not reliable. You should have a variable set from within your main scan which is used to trigger the sending of the email within your slow sequence. The first example in the CRBasic help for FTPClient shows how to use the OutStat result from TableFile.

In regards to question 2, you would need to check the value of EmailSuccess to see if the email was successfully sent. If it failed, retry.

Here is a simplified example of doing retries on EmailSend:

For i = 1 to 3
EmailSuccess = EmailSend(............)
If EmailSuccess <> 0 then ExitFor
Next i

Log in or register to post/reply in the forum.