Daggos

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

Share this post


Link to post
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

Share this post


Link to post
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()

 

 

Share this post


Link to post
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])

 

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

1 other thing how would i make New values in Bold text

semail.strBody = "New values: " + CRLF

Share this post


Link to post
Share on other sites

You'd have to mark the email as html, then use html tags.  Something like:

semail.strBody = "<b>New values:</b>: " + CRLF

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now