Menu

MailCompose Demo and MessageDlg

JR
2015-06-02
2015-06-12
  • JR

    JR - 2015-06-02

    Since discovering the D.P.F Delphi iOS Native Components, I have been playing with some of the demos in order to have a better understanding of the components themselves.

    Using Delphi XE8, I am currently testing the 'MailCompose' demo. I have no problem with the demo itself if I run it as is. Indeed, this works properly (the e-mail is sent to my e-mail app):

      SL := TStringList.Create;
      try
        SL.Add( 'This is a sample attachment file content. create by TDPFMailCompose' );
        SL.SaveToFile( GetTempDirectory + 'DPFSampleAttach.txt' );
        if not DPFMailCompose1.MailCompose( DPFTextFieldSubject.Text, DPFTextViewBody.Text, False, [DPFTextFieldRecipient.Text], [], [], [GetTempDirectory + 'DPFSampleAttach.txt'] ) then
          ShowMessage( 'Sorry' + #10#13 + 'You cant send eMail '#10#13 + '1) Your Device not support eMail Compose' + #10#13 + '2) You not have a Mailbox' );
      finally
        SL.Free;
      end;
    

    However, if I attempt to request a user confirmation (via a call to 'MessageDlg') prior to calling 'DPFMailCompose1.MailCompose,' the e-mail is not sent to my e-mail app:

      if (MessageDlg(('Do you really want to send an e-mail?'), TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0, TMsgDlgBtn.mbNo) = mrNo) then
        Exit;
    
      SL := TStringList.Create;
      try
        SL.Add( 'This is a sample attachment file content. create by TDPFMailCompose' );
        SL.SaveToFile( GetTempDirectory + 'DPFSampleAttach.txt' );
        if not DPFMailCompose1.MailCompose( DPFTextFieldSubject.Text, DPFTextViewBody.Text, False, [DPFTextFieldRecipient.Text], [], [], [GetTempDirectory + 'DPFSampleAttach.txt'] ) then
          ShowMessage( 'Sorry' + #10#13 + 'You cant send eMail '#10#13 + '1) Your Device not support eMail Compose' + #10#13 + '2) You not have a Mailbox' );
      finally
        SL.Free;
      end;
    

    Am I missing something?

     
  • justapps

    justapps - 2015-06-12

    I remember trying this too. I think the Messagebox is place behind the mail screen. I wonder if using an anonymous method would allow it to work correctly.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.