MailComposer and MessageComposer types from the iPhone library allow the user to send mails and SMS messages from your app. The users will see a pre-filled form which they can modify and send.
(press on the small gear button and set the quality to HD)
Not all devices support these two features. You should check whether the feature is supported or not. In this example it is done with this code:
The next step is to dim and initialize MailComposer or MessageComposer, fill the fields and show the composer:
The Complete event will be raised with the result:
The project is attached.
(press on the small gear button and set the quality to HD)
Not all devices support these two features. You should check whether the feature is supported or not. In this example it is done with this code:
B4X:
mailButton.Enabled = mailc.CanSendMail
smsButton.Enabled = smsc.CanSendText
The next step is to dim and initialize MailComposer or MessageComposer, fill the fields and show the composer:
B4X:
Private Sub SendMail
'always dim and initialize the MailComposer before you use it
Dim mailc As MailComposer
mailc.Initialize("mailc")
mailc.SetToRecipients(Array("hello@example.com", "world@example.com"))
mailc.SetSubject("This is the subject")
mailc.SetBody("This is the <b>body</b>.", True)
'create a file and add it as an attachment
File.WriteString(File.DirTemp, "1.txt", "hello world")
mailc.AddAttachment(File.DirTemp, "1.txt", "text/plain")
mailc.Show(Page1)
End Sub
The Complete event will be raised with the result:
B4X:
Sub Mailc_Complete (Result As Int)
If Result = mailc.RESULT_SENT Then
hd.ToastMessageShow("Message sent", True)
Else
hd.ToastMessageShow("Message was not sent", True)
End If
End Sub
The project is attached.