Sending Mails

edited February 2010 in General
Hello

I am using D2009 and RB 11.06 and I would like to control if a report was
sent by mail or not. I was reading in the news group and I found that this
is possible by using "OnStatusChanged", but it does not work for me.

I did the following

Procedure TForm1.FormCreate ;
begin
TppEmail(Report.Email).SMTP.OnStatusChange := EmailStatusChangeEvent;
end;

procedure Tfreport.EmailStatusChangeEvent(Sender : TObject);
var
tempEmailBodyText: String;
tempMAPIComponent: TppSMTPMapi;
tempMAPIStatus: String;
I: Integer;
begin
tempMAPIComponent := Sender as TppSMTPMapi;
tempMAPIStatus := tempMAPIComponent.Status;
if tempMAPIStatus = 'Success' then
begin
ShowMessage('The mail was sent');
end;
end;


Can you help me or provide me an example of how I can control this?

Regards

Jesus Mendez
Resilux Iberica

Comments

  • edited February 2010
    Hi Jesus.

    In my testing with the code below, the status event fired correctly giving
    the proper values. I noticed that your event is not a member of the class
    that defines it.

    uses
    ppEmail, ppSMTPMapi;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    TppEmail(ppReport1.Email).SMTP.OnStatusChange := EmailStatusEvent;

    ppReport1.SendMail;

    end;

    procedure TForm1.EmailStatusEvent(aSender: TObject);
    begin
    ShowMessage(TppSMTPMapi(aSender).Status);

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2010
    Ok. But I use to send the mail, the button inside the report preview.And
    using this way, this does not work.

    Please let me know.

    Regards


  • edited February 2010
    Hi Jesus,

    Just tested it with the Preview email button and it worked the same.

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    TppEmail(ppReport1.Email).SMTP.OnStatusChange := EmailStatusEvent;

    ppReport1.EmailSettings.Enabled := True;

    ppReport1.Print;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

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