Onchange "Vessel_Batch", "@New_Email()" Onchange "Vessel_Cycle_NO","@WriteToFile()" Function WriteToFile() Open "file:/usr/" + STR$ Vessel_Batch@ + "_Report.csv" FOR BINARY APPEND AS 1 //This creates a new file as well as names it based off the vessel batch number If Vessel_Cycle_No@ = 1 Then Put 1, "Vessel Batch No;Vessel Cycle No;Max Vac(mbar);Max Pressure(bar);Cycle Time(s)" + CHR$(13) + CHR$(10) // writes the names for each column Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + STR$ Cycle_Time@ + CHR$(13) + CHR$(10) //calls the values, semicolon delimited Else If Vessel_Cycle_No@ = 2 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + STR$ Cycle_Time@ + CHR$(13) + CHR$(10) Else If Vessel_Cycle_No@ = 3 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + STR$ Cycle_Time@ + CHR$(13) + CHR$(10) Else If Vessel_Cycle_No@ = 4 Then Put 1, STR$ Vessel_Batch@ + ";" + STR$ Vessel_Cycle_No@ + ";" + STR$ Max_Vac@ + ";" + STR$ Max_Pressure@ + ";" + STR$ Cycle_Time@ + CHR$(13) + CHR$(10) Else Endif Endif Endif Endif Close 1 Print "file written" EndFn Function New_Email() oldval% = Vessel_Batch@ - 1 // so that when the value increments it will grab the previously created data $EmailTo$ = "Johnsmith@email.com" $EmailCC$ = "mark@email.com" $EmailSubject$ = STR$ oldval% + " Report" $EmailBody$ = "" $EmailBody$ = $EmailBody$ + "Third Line " + CHR$(13) + CHR$(10) // the CHR$(13) + CHR$(10) is the same as newline $EmailBody$ = $EmailBody$ + "Second Line" + CHR$(13) + CHR$(10) // Second line of email $EmailBody$ = $EmailBody$ + "Third Line" + CHR$(13) + CHR$(10) // Third Line of email... ect $EmailBody$ = $EmailBody$ + "Time: " + TIME$ + CHR$(13) + CHR$(10) // Gives the full date when this was sent // Want to include data such as graphs as an attachment? see: https://ewonsupport.biz/ebd/ $EmailAttachment$ = "&[$dtUF$uf/usr/" + STR$ oldval% + "_Report.csv$ftT]" $EmailContents$ = $EmailBody$ + $EmailAttachment$ SENDMAIL $EmailTo$, $EmailCC$, $EmailSubject$, $EmailContents$ Print "mail sent" Endfn