Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Data in email body

edited November 2014 in General
Hi,

I have a report which I mail to customers. In the EmailSettings of the
report I give a short summary of the report that is attached to the
email. In the summary I use both plain text and text I get out of my db.

However, when I want to email the report. The body of the email only
shows the plain text and the data that should come out of the db remains
blank.
The data is correctly filled in when I first open the print preview and
then send the report as email, but I rather want to be able to email the
reports directly with a proper email body.

I am using RB Enterprise 15.01 build 283 with Delphi XE2, is this
problem that is fixed in a newer version or if not, what should I do to
get it working?

Thanks in advance,
Ruben Bijl

Comments

  • edited November 2014
    Hi Ruben,

    I am unclear about what you mean by missing data. ReportBuilder simply
    generates the report as a file and automatically attaches it to an email
    before sending. Is there data missing from the attached report file?
    If you generate the report directly to file, is the data present?

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2014
    Hi Nico,

    The report itself is fine, it's just that I use some of my database data
    in the body of the email so that the user has a summary in the email as
    to what is in the attachment.

    Regards,
    Ruben

    Nico Cizik (Digital Metaphors) schreef op 4-11-2014 om 15:18:
  • edited November 2014

    Adding data to the email body is not a built-in feature of
    ReportBuilder. The email body is completely controlled by the
    EmailSettings.Body property. Please give more information about how you
    are doing this and perhaps we can offer some ideas on how to get the
    effect you are after.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2014
    In my program I have a grid which shows the invoices that I currently
    need to send to my customers. When I select an item and press the 'Send
    as email' button, the report is perfectly build and added as attachment
    to the email.
    But, I want to give the body of the email a proper text, like the
    correct salutation and name of the contact person that I'm sending the
    invoice to.
    So I added in the OnBeforeEmail event in the report the following code:

    procedure ReportBeforeEmail;
    begin
    // snip

    Report.EmailSettings.Body.Clear;
    Report.EmailSettings.Body.Add('Dear '+ CP_PERS['CP_SALUT']+' '+
    CP_PERS['CP_NAME'] + ',');
    Report.EmailSettings.Body.Add('');
    Report.EmailSettings.Body.Add('Attached to this email you will find
    your invoice #' + FC_INV['FC_NR'] + '.');
    //snip
    end;

    If I first make a print preview of the report and the press the email
    button the email it creates has the following text in its body:

    Dear mr. Bijl,

    Attached to this email you will find your invoice #00479.
    (...)

    But when i use the button to directly send it as email the body of the
    email is missing the data it should get from the database, so the email
    looks like this:

    Dear ,

    Attached to this email you will find your invoice #.
    (...)

    So what am I missing in that I can get the same email body without
    opening the print preview first?
    Again, thanks in advance for looking into this problem.

    Regards,
    Ruben

    Nico Cizik (Digital Metaphors) schreef op 4-11-2014 om 16:39:
  • edited November 2014
    Hi Ruben,

    The issue is timing. The BeforeEmail event fires before the report
    opens the datapipelines. My suggestion would be to either access your
    dataset directly to populate the body, or use a different event such as
    the AfterOpenDataPipelines.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2015
    Nico Cizik (Digital Metaphors) schreef op 5-11-2014 om 16:19:
    Hi Nico,

    Do you or anyone know if you can 'manually' open the DataPipelines in
    code. Because the SendMail-event is also called from code, which may
    bypass the whole DataPipeLine events.
  • edited April 2015
    Hi Ruben,

    A pipeline can be manually opened using the Open command. I recommend
    directly accessing your datasets instead of using the pipelines.
    Pipelines are primarily used with reports only.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2015
    Nico Cizik (Digital Metaphors) schreef op 8-4-2015 om 18:17:


    Hi Nico,

    I thought that I already was accessing the datasets directly with
    commands like
    CP_PERS['CP_SALUT']+' '+ CP_PERS['CP_NAME']

    If this is not case, could you please tell me how to access the datasets
    or where I can find the proper documentation for it?
    Thanks so far for all your help!

    Regards,
    Ruben
  • edited April 2015
    Hi Ruben,

    DataPipelines are not datasets. They allow the report to easily access
    and traverse your dataset objects and populate the report with data.

    My suggestion is to gather the data for the email body before printing
    the report.

    lsDataBody := MyDataSet['MyDataField'];

    Report.EmailSettings.Body.Add(lsDataBody);

    Report.SendMail;

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2015
    Nico Cizik (Digital Metaphors) schreef op 10-4-2015 om 16:08:

    Hi Nico,

    So that means that I can only use datasets and thus the data in the code
    of making the report and not in the report itself written in an event
    like BeforeEmail or OnEndSecondPass?
  • edited April 2015
    Hi Ruben,

    For the purpose of populating body of the email, yes. As I mentioned
    before, the report events fire too late to populate the email body. The
    BeforeEmail event fires early enough however you will need to access
    your data separate from the report because the pipelines have not begun
    accessing any data at that point.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2015
    Nico Cizik (Digital Metaphors) schreef op 14-4-2015 om 15:38:

    Hi Nico,

    I think I was not clear enough about the fact that this is about an
    end-user script. I'm not trying to implement a BeforeEmail event handler
    in Delphi, but the end-user is creating a BeforeEmail event handler
    inside the report definition. This end-user cannot reach the underlying
    (Delphi) data source other than by using the data pipeline, can he do
    that? Or is this possible by some means I am not aware of?

    Regards,
    Ruben
  • edited April 2015
    Hi Ruben,

    Thanks for the clarification. For future reference, please let us know
    which features you are using or post to the appropriate newsgroup (RAP
    newsgroup).

    Unfortunately RAP events fire too late to alter the email settings.
    This is due to the fact that all RAP events fire during Report
    generation, however all email settings are assigned before generation.

    Though it would take a complete re-design, we will consider altering
    this limitation for a later release.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.