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

Unsafe implementation of TppEmail.DisplayEmailDialog

edited May 2013 in General
Hello,
there is a hard re-typing in the procedure TppEmail.DisplayEmailDialog.
This causes problems when I want to use my own e-mail send dialog.
Please, can you change the source code to in the following way?
It will keep existing functionality and allows other users to implement
their own email send dialogs by extending TppCustomEmailDialog class.
Best regards, Igor Gottwald

unit ppEmail.pas

procedure TppEmail.DisplayEmailDialog;
var
{inserted}lEmailDialog: TppCustomEmailDialog;
{removed
lEmailDialog: TppEmailDialog;
}
lFormClass: TFormClass;
begin

lFormClass := ppGetFormClass(TppCustomEmailDialog);

{inserted start}
lEmailDialog := TppCustomEmailDialog(lFormClass.Create(nil));
{inserted end}
{removed
lEmailDialog := TppEmailDialog(lFormClass.Create(nil));
}

try
{inserted start}
if (lEmailDialog is TppEmailDialog) then
TppEmailDialog(lEmailDialog).Menu.ConnectionMenu
.Visible := FSMTP.LoginRequired;
{inserted end}
{removed
lEmailDialog.Menu.ConnectionMenu.Visible := FSMTP.LoginRequired;
}

if FEmailSettings.FileName = '' then
FEmailSettings.FileName := FReport.PrinterSetup.DocumentName;

lEmailDialog.EmailSettings := FEmailSettings;

{ Display the email dialog }
lEmailDialog.ShowModal;

if lEmailDialog.ModalResult = mrOk then
begin
{ Assign the new emailsettings to the email }
FEmailSettings.Assign(lEmailDialog.EmailSettings);

ProcessAndSend;
end;

finally
lEmailDialog.Free;
FEmailSettings.Clear;
FReports.Clear;
end;

end; { procedure, DisplayEmailDialog }

Comments

  • edited May 2013
    Sorry for missing RB version in my previous post.
    The described behaviour is in RB 14.08 for XE3
    Best regards, Igor Gottwald

    In article ,
    gottwald@oksoftware.cz says...
  • edited May 2013
    Thanks for pointing this out. I corrected our code base to use
    TppCustomEmailDialog. For the next major release will add a public boolean
    property, TppEmailSettings.LoginRequired, so that this can be handle without
    requiring a typecast to TppEmailDialog. We can just assign the
    EmailSettings.LoginRequired property and let the dialog configured its menu
    option.



    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.