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

PDF Attachment not showing as an attachment

edited January 2012 in General
I just upgraded a project to ReportBuilder 14.02.

In testing email of a report, the email does not show the attachment as
a normal attachment that can be clicked and downloaded or viewed.
Instead, the attachment shows in the body of the email as gibberish. I
have tried sending to both GMail and Yahoo web mail, and it is the same
in both.

Below is what the top part of the email has:

============================
This is a multi-part message in MIME format

--UGppb1t8aBYXrAk=_6t2lLxsAwTh7jNHcY
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Test 3

--UGppb1t8aBYXrAk=_6t2lLxsAwTh7jNHcY
Content-Type: application/octet-stream;
name="Report.PDF"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="Report.PDF"

JVBERi0xLjINCjEgMCBvYmoNCjw8IC9UeXBlIC9DYXRhbG9nIA0KL1BhZ2VzIDMgMCBSIA0K
L1Zp
ZXdlclByZWZlcmVuY2VzIDw8IA0KPj4NCj4+IA0KZW5kb2JqDQo1IDAgb2JqDQo8PCAvVHlw
ZSAv
UGFnZSANCi9QYXJlbnQgN
============

There is a lot more of the gibberish on the end. I cut it to save
space.

How can I fix this so that what is sent is readable?


--

Comments

  • edited January 2012
    Hi David,

    This is not a known issue with RB 14.02 nor have we ever seen anything
    like this in the past.

    Which email plugin are you using to send emails? Which version of
    Delphi are you using?

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2012
    Hi Nico.

    I am using Delphi 2007 and sending from the preview window, using Indy
    10. I am not using an Email client application.

    The email's Content-Disposition says inline instead of attachment. Can
    you tell me what variables might affect that?


  • edited January 2012
    Hi David,

    By default, Indy should attach files as attachments. ReportBuilder does
    not handle the attachment process. It simply gives the TidSMTP object
    the files to attach and Indy takes over from there.

    Are you using the version of Indy that came with Delphi 2007? It is
    possible that this is a bug in that version so you might want to upgrade
    and see if that helps. Did this function correctly before you upgraded
    to RB 14.02 (using the same version of Delphi etc.)?

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2012
    Hi Nico.

    This functioned correctly when I was using RB 10. The problem appeared
    after updating to RB 14.

    When I first started Delphi, there were several error messages. Some
    were related to the rbRCL10105.bpl not being found, and
    rbNexusDB10105.bpl not being found. I told Delphi not to load these
    anymore, and I recompiled the rbNexusDB packages for the newer version
    of ReportBuilder.

    There was one message that flashed on the screen about IdMessage class
    not being found. However, I never saw it again, and a build of my
    application was successful, so I figured everything was fine. I do not
    know what unit the IdMessage thing was about, so I don't know what to
    do about it, but it very well could be related to this problem.

    I have tried two different mail senders, both yahoo and gmail, as well
    as sending to two different receivers (yahoo and gmail). I have tried
    using secure mail through two different ports (465 for yahoo and 567
    for gmail) and also unsecure mail through port 25. All have the same
    problem.

    I am not using the Indy that came with Delphi 2007 because I had to
    update that some a few years back to get secure http connections to
    work. I will look into that now, to see if I can update Indy 10. I'm
    a little afraid to do it because updating was a pain last time, to get
    the right version of the secure dll's to work with the right version of
    Indy (not all version 10's are the same). I am using Indy in other
    areas of my program and I can't break those areas. This was suppose to
    be my last update before I fully port the application over to Delphi
    XE. The Unicode stuff in Delphi XE was taking me longer than expected,
    and I had a reason to update this application in Delphi 2007 with RB
    14. Now I am regretting that decision. I can roll back to prior
    backup, but then I lose a whole days work. I had thought everything
    was fine, so I did other coding stuff. Now I see there is a problem,
    but I hate to lose all that other work.

    One thing different I have noticed is that the Report Template holds
    email information in RB 14 and I do not think it did in RB 10. I use
    to set email settings before the template was loaded. Now, I see that
    I have to move that to after LoadFromFile.

    Below is the routine I use now to set the email settings. Can you look
    it over and see if you notice anything wrong or incomplete with it? I
    added a EmailSettings.Clear at the start. Hope that is ok. I use to
    just clear attachments. I have modified this routine since updating to
    version RB 14.02, trying to get things to work. Part of what I did was
    add the ability to send secure email through gmail using info from your
    wiki.

    Thanks, Nico.

    Best regards,
    David.

    p.s. Sorry for the long post. I will be looking at solutions through
    perhaps an Indy update, and also searching newsgroups about this
    problem with Indy. If you can comment on my code below and offer any
    other suggestions, I would appreciate it. Thanks.

    ==============

    procedure TdmRep1.DataModuleCreate(Sender: TObject);
    begin
    wIOHandler:=TIdSSLIOHandlerSocketOpenSSL.Create(Self);
    end;

    procedure TdmRep1.DataModuleDestroy(Sender: TObject);
    begin
    wIOHandler.Free;
    end;

    procedure TdmRep1.EmailErrorEvent(Sender: TObject;aErrorText: string);
    begin
    if (aErrorText<>'Connection Closed Gracefully') then
    begin
    MessageBeep(mb_IconAsterisk);
    MessageDlg('Email Error: '+aErrorText,mtError,[mbOk],0);
    end;
    end;

    procedure TdmRep1.SetEmailVars(var Rep: TppReport;UseCustEmail: char);
    var
    rc,rc1,rc2: string;
    begin
    with Rep.EmailSettings do
    begin
    Rep.EmailSettings.Clear;
    TppEmail(Rep.Email).SMTP.OnEmailError:=EmailErrorEvent;
    Enabled:=true;
    PreviewInEmailClient:=false;
    ShowCancelDialog:=false;
    ShowEmailDialog:=true;

    FromAddress:=EmailFromAddr;
    FromName:=EmailFromName;
    ReplyTo:=EmailReplyTo;
    Subject:=EmailSubject;

    // Setup Recipient Using Customer's Email and CoEmail if they exist
    if (UseCustEmail='Y') then
    begin
    rc1:=Trim(dmRep1.tbCust.FieldByName('Email').AsString);
    rc2:=Trim(dmRep1.tbCust.FieldByName('CoEmail').AsString);
    if (rc1='') then rc:=rc2
    else if (rc2<>'') then rc:=rc1+','+rc2
    else rc:=rc1;
    if (rc='') then // If No Cust Email
    begin // Use Standard Email Setup From Store Table
    Recipients.CommaText:=EmailRecipients;
    CarbonCopy.CommaText:=EmailCC;
    BlindCarbonCopy.CommaText:=EmailBCC;
    end
    else
    begin // Set Addresses Found In Cust table
    Recipients.CommaText:=rc;
    CarbonCopy.CommaText:='';
    BlindCarbonCopy.CommaText:='';
    end
    end
    else // If Not UseCustEmail
    begin // Use Standard Email Setup From Store Table
    Recipients.CommaText:=EmailRecipients;
    CarbonCopy.CommaText:=EmailCC;
    BlindCarbonCopy.CommaText:=EmailBCC;
    end;

    UserName:=EmailUserName;
    Password:=EmailPW;
    HostAddress:=EmailHostName;
    if EMailReportFormat='' then ReportFormat:='PDF'
    else ReportFormat:=EMailReportFormat;

    // Setup for Secure Email or Port is other than 25
    if (EmailTLSFlag<>'') or (EmailPort<>25) then
    begin
    wEmail:=TppEmail(Rep.Email);
    wIOHandler.Destination:=EmailDest;
    wIOHandler.Host:=EmailHostName;
    wIOHandler.Port:=EmailPort;
    TppSMTPIndy(wEmail.SMTP).IndySMTP.Port:=EmailPort;
    TppSMTPIndy(wEmail.SMTP).IndySMTP.IOHandler:=wIOHandler;
    if (EmailTLSFlag='1') then
    TppSMTPIndy(wEmail.SMTP).IndySMTP.UseTLS:=utUseExplicitTLS
    else if (EmailTLSFlag='2') then
    TppSMTPIndy(wEmail.SMTP).IndySMTP.UseTLS:=utUseRequireTLS;
    // If TLSFlag='', Then Does Not Set UseTLS At All
    end;
    end; // With Rep.EmailSettings Do
    end;
    ----

  • edited January 2012
    Correction. I just tested the older version of the app, and it is
    doing the same thing, so RB 10 did not work either. It may be that
    when I updated Indy sometime back, it broke RB and I just did not know
    it.

    I'm trying to update Indy using SVN, but am having problems. It gives
    me an access forbidden message after typing the login. I am not real
    familiar with Tortoise SVN, so am having issues trying to update.

    Do you have a link to the Indy 10 files that you know work well with
    RB?


  • edited January 2012
    I found a link to zipped update at:
    http://indy.fulgan.com/ZIP/

    I'll give that a try and let you know how it goes.


  • edited January 2012
    Hi David,

    Thanks for the link.

    Indy is a very dynamic product in that it is perpetually being updated
    and changed. Since ReportBuilder only uses a very small portion of the
    product, it is generally our policy to find a version that functions
    correctly and stick with it as long as possible.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2012
    Hi Nico.

    After going through hell and back trying to get Indy installed, I
    finally got Indy updated from version 10.5.7 to 10.5.8.

    One issue was that I never removed the files for the version of Indy
    that came with Delphi 2007, so I think your installation was using
    those source files instead of the new ones. I had to uninstall
    ReportBuilder to get Indy to install into the IDE.

    The problem with the email attachment now works as it should!

    Thanks for being there through all my troubles. :-)


    --
  • edited January 2012
    Hi Nico.

    I wish someone would take the time to build the BPL's for various
    versions of Delphi and allow us to download those. I was working from
    3:00 am this morning until 9:50 am trying to build the BPL's and get
    them installed.

    The instructions from Indy say:
    http://www.indyproject.org/sockets/Docs/Indy10Installation.en.aspx

    ===============
    You can either:

    1) use the command-line FULLD#.BAT script that corresponds to your
    Delphi version.

    2) Open the individual .dpk files in the IDE and compile them, in the
    following order:

    IndySystemX0.dpk (in Lib\System)
    IndyCoreX0.dpk (in Lib\Core)
    IndyProtocolsX0.dpk (in Lib\Protocols)
    dclIndyCoreX0.dpk (in Lib\Core)
    dclIndyProtocolsX0.dpk (in Lib\Protocols)
    If you encounter the following linker error:

    RLINK32: Error opening File packagename.drf

    Try this workaround:

    Delete all .DCP and .BPL files for the package.
    Open the .DPK file in the IDE, go into its Project Options, and set the
    Build Control setting to "Explicit Rebuild".
    Rebuild the package.
    Repeat these steps for each dependant package.
    ==============

    Well, the FullD#.BAT script did not work, and trying to do it manually
    was a chore filled with frustration. I would get the "error opening
    .drf" described above, but when I followed their recommendation to do
    "Explicit Rebuild" then I would get a "Never-build package xxx requires
    always-build package xxx." I kept going around and around between
    these type of messages. Finally I decided to take matters into my own
    hands and edited the source files for all the packages to have
    ImplicitBuild OFF. Then I deleted all the BPL/DCP's and started
    building the packages. This created multiple copies of the BPL's, but
    then I just copied the BPL's needed into my BPL folder and installed
    the two dcl files, dclIndyCoreX0.bpl and dclIndyProtocolsX0.bpl. Well,
    they wouldn't install at first, but I deduced that I should uninstall
    ReportBuilder because a reference was made to them in the error
    message. Finally, with no ReportBuider, it installed. What a mess.
    Reinstalled ReportBuilder 14.02, and now, nearly 7 hours later, I am
    back in business. :-)

    The word is that for Indy 11, they plan to have a better install
    method. I hope that comes true.


This discussion has been closed.