Multiple variables/channels in email


Recommended Posts

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])

Link to comment
Share on other sites

// 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

Link to comment
Share on other sites

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()

 

 

Link to comment
Share on other sites

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])

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.