Daggos Posted June 15, 2020 Share Posted June 15, 2020 Hi I'm using the below email script to send emails which is fine but i cant get more than 1 channel to show up in the email body. It will only show the last channel on the line? Do i have to set up an array? or another option is to save it to a file and send the file but i want it in the email body. private semail = new(CEMail) semail.strhost = "smtp.gmail.com" semail.port = 587 semail.strUserName = "xxxx" semail.strPassword = "xxxx" semail.strAuthenticate = "Auto" semail.strBody = "text " (HV_Power_Bulk_Fuel [0]) (Ventfan_Fan2_Vib_DE[0]) semail.strReplyAddress = "xxxx" semail.strReplyName = "xxxxx" semail.strSubject = "xxxx" semail.strTo = "xxxxxx" semail.strConnectionType = "STARTTLS" semail.strSSLProtocol = "TLSv1_2" semail.Send() Also another issue i dont seem to be able to send the average just sends the current value Mean(PS_2_Flow_Outlet[0,1600]) Quote Link to comment Share on other sites More sharing options...
Daggos Posted June 15, 2020 Author Share Posted June 15, 2020 // open the file private.handle = File.Open("c:\mydata.csv",1,0,0,0) // get the length private.length = File.GetLength(handle) // read the entire file and put into the body of the email email.strBody = File.Read(handle, length) // close the file file.Close(handle) Found this on another thread i guess this would work? still would like to know if i can add more channels to an email direct Quote Link to comment Share on other sites More sharing options...
Daggos Posted June 15, 2020 Author Share Posted June 15, 2020 Ok this wont work either no email and daqfactory hangs private semail = new(CEMail) semail.strhost = "smtp.gmail.com" semail.port = 587 semail.strUserName = "xxxx" semail.strPassword = "xxxx" semail.strAuthenticate = "Auto" // open the file private.handle = File.Open("d:\DAQFactory\data.csv",1,0,0,0) // get the length private.length = File.GetLength(handle) // read the entire file and put into the body of the email email.strBody = File.Read(handle, length) // close the file file.Close(handle) semail.strReplyAddress = "xxxx" semail.strReplyName = "xxxxx" semail.strSubject = "xxxx" semail.strTo = "xxxxxx" semail.strConnectionType = "STARTTLS" semail.strSSLProtocol = "TLSv1_2" semail.Send() Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 15, 2020 Share Posted June 15, 2020 The problem is that you aren't creating the body correctly. This line: semail.strBody = "text " (HV_Power_Bulk_Fuel [0]) (Ventfan_Fan2_Vib_DE[0]) Is invalid. You need to build up the string in the format you want. For example: semail.strBody = "New values: " + HV_Power_Bulk_Fuel[0] + ", and: " + VentFan_Fan2_Vib_DE[0] + ", average: " + Mean(PS_2_Flow_Outlet[0,1600]) Quote Link to comment Share on other sites More sharing options...
Daggos Posted June 16, 2020 Author Share Posted June 16, 2020 Thanks that works perfectly Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 16, 2020 Share Posted June 16, 2020 Note you can add a new line by doing something like: private string CRLF = chr(13) + chr(10) semail.strBody = "New values: " + CRLF semail.strBody += "Power Fuel: " + HV_Power_Bulk_Fuel[0] + CRLF semail.strBody += "Vent Fan: " + VentFan_Fan2_Vib_DE[0] + CRLF semail.strBody += "Average: " + Mean(PS_2_Flow_Outlet[0,1600]) + CRLF Quote Link to comment Share on other sites More sharing options...
Daggos Posted June 16, 2020 Author Share Posted June 16, 2020 Nice thanks i will use that. Quote Link to comment Share on other sites More sharing options...
Daggos Posted June 17, 2020 Author Share Posted June 17, 2020 1 other thing how would i make New values in Bold text semail.strBody = "New values: " + CRLF Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 18, 2020 Share Posted June 18, 2020 You'd have to mark the email as html, then use html tags. Something like: semail.strBody = "<b>New values:</b>: " + CRLF Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.