The D.P.F Delphi iOS Native Components by b_yaghobi on the Sourceforge repository provides components for composing/sending emails using Delphi XE-4 and XE-5 on the iOS target platform. Sending an email is as simple as dropping a TDPFMailCompose component on a FIreMonkey mobile application form and calling the MailCompose method. The component package comes with a demo (MailCompose) to demonstrate how this works, but i have included the two important code snippets for your review. The first is the send mail button’s OnClick event which calls the MailCompose method passing it the information gathered from the other controls on the form. The next is the send status event, which fills a label on the form with the status of the sent message.
procedure TFMailCompose.DPFButtonSendMailClick( Sender: TObject );
SL := TStringList.Create;
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' );
procedure TFMailCompose.DPFMailCompose1SendStatus( Sender: TObject; Result: Integer );
StatusMessage: array [0 .. 3] of string = ( 'MailCompose Cancelled', 'MailCompose Saved', 'MailCompose Sent', 'MailCompose Failed' );
DPFLabel1.Text := StatusMessage[Result];
Stop on over to SourceForge and download the D.P.F Delphi iOS Native Components and starting sending email messages from your Delphi iOS applications today.
Send Email On IOS Using Delphi XE5 Firemonkey by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.