Sending an email from cbus- with data

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Hellohumpage, May 22, 2013.

  1. Hellohumpage

    Hellohumpage

    Joined:
    May 22, 2013
    Messages:
    3
    Likes Received:
    0
    Location:
    Geelong
    I was wondering if anybody has a solution for sending an email from cbus. I have a lot of data stored within a ctouch panel.

    I would like to send out a daily email containing system I/O values and a bit of text.

    I just realised that the ctouch can only send one line of text, that does not contain any stored values


    Any ideas??
     
    Hellohumpage, May 22, 2013
    #1
  2. Hellohumpage

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You can email any text you wish, including data. You just need to put the text and data into a string variable and then email it.

    For example, if you have a string called MyString:

    Code:
    Format(MyString, 'Data = ', GetRealSystemIO("My Variable"):6:2);
    SendEMail(0, '[email protected]', 'test', MyString);
    
    If the value of the user system IO variable called "My Variable" was 1.23456, then the body of the e-mail would be:

    Data = 1.23
     
    Darren, May 25, 2013
    #2
  3. Hellohumpage

    Hellohumpage

    Joined:
    May 22, 2013
    Messages:
    3
    Likes Received:
    0
    Location:
    Geelong
    Thanks Darren,

    That sounds easy, thanks. I was just reading in the logic manual that you can only send one line in the email. Is there a way around this? Is there a restriction on the number of characters in this command line?

    So for example if I wanted to send a few system I/O variables in the one email.

    Say the email would read something like this
    ==========================================
    Subject: Cbus Communication

    Todays solar generation - 30kWh (the value would be generated from the logic)
    Todays power consumption - 20kWh (the value would be generated from the logic)
    Rain today - 5.0mm
    ==========================================

    is the logic engine capable of doing this or is there another product or way I can achieve this?
     
    Hellohumpage, May 25, 2013
    #3
  4. Hellohumpage

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You can make the text as long as you like. You will need to declare the string variable to be longer than the default 50 characters (see help file for how to do this). You can also add carriage return and line feed characters to the string so that you effectively get multiple lines of text.

    First, declare your big string variable:
    Code:
    EMailString: array[0..500] of char;
    Second, build up the string:

    Code:
    Format(EMailString, 
    'Todays solar generation -', GetRealSystemIO("Solar"):6:1, 'kWh', #13#10, 
    'Todays power consumption -',GetRealSystemIO("Consumption"):6:1, 'kWh', #13#10, 
    'Rain today -', GetRealSystemIO("Rain"):6:2, 'mm');
    Then e-mail it:

    Code:
    SendEMail(0, '[email protected]', 'Cbus Communication', EMailString);
     
    Darren, May 26, 2013
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.