mobileComposeMail

Typecommand
DictionaryLCS
LibraryLiveCode Script
Syntax
mobileComposeMail <subject>, [<recipients>, [<ccs>, [<bccs>, [<body>, [<attachments>]]]]]
Synonymsiphonecomposemail
Summary

Opens a new email message in the user's email program.

Introduced4.6
OSios, android
Platformsmobile
Parameters
NameTypeDescription
subject

The subject line of the email.

recipients

A comma delimited list of email addresses to be placed in the 'To' field.

ccs

A comma delimited list of email addresses to be placed in the 'CC' field.

bccs

A comma delimited list of email addresses to be placed in the 'BCC' field.

body

The body text of the email.

attachments

Either empty to send no attachments, a single attachment array or a one-based numeric array of attachment arrays to include. The attachments parameter consists of either a single array, or an array of arrays listing the attachments to include. A single attachment array should consist of the following keys:

  • "data": The binary data to attach to the email (not needed if a file is present).
  • "file": The filename of the file on disk to attach to the email (not needed if data present).
Example
mobileComposeMail
local tAttachment
mobileComposeMail "Test E-mail", "guido@example.net",,, "This is the e-mail body text", tAttachment
mobileComposeMail "Help", "help@example.com",,,field "Message"
local tAttachment
put "Hello World!" into tAttachment["data"]
put "text/plain" into tAttachment["type"]
put "Greetings.txt" into tAttachment["name"]
mobileComposeMail "Greetings", "test@livecode.com",,,, tAttachment
-- Attach an image --
local tAttachment
put image 1 into tAttachment["data"]
put "image/gif" into tAttachment["type"]
put "my picture" into tAttachment["name"]
mobileComposeMail "Image Example", "test@livecode.com",,,, tAttachment
Values
NameTypeDescription
The result

Set by mobileComposeMail to indicate its results.

sent (iOS): the email was sent successfully
cancel (iOS): the email was not sent, and the user elected not to save it for later
unknown (Android): On Android the email activity does not return its status back to the calling activity so the result is set to 'unknown' in all cases
RelatedCommand: revMail, revGoURL, revMailUnicode, mobileComposeUnicodeMail, mobileComposeHtmlMail
Function: mobileCanSendMail
Glossary: command
Object: stack
Description

Use the mobileComposeMail command to create a text email message with attachments from within a stack on iOS or Android.

This command interfaces with the iOS and Android mail composition interface.

If you specify a file for the attachment, the engine tries to use the least amount of memory by asking the operating system to only load it from disk when the file is needed. Therefore, using mobileComposeMail should be the preferred method when attaching large amounts of data to an e-mail. For example, sending multiple attachments may be done like this:

 local tAttachments
 put "Hello World!" into tAttachments[1]["data"]
 put "text/plain" into tAttachments[1]["type"]
 put "Greetings.txt" into tAttachments[1]["name"]
 put "Goodbye World!" into tAttachments[2]["data"]
 put "text/plain" into tAttachments[2]["type"]
 put "Farewell.txt" into tAttachments[2]["name"]
 mobileComposeMail tSubject, tTo, tCCs, tBCCs, tBody, tAttachments

Some devices are not configured with e-mail sending capability. To determine if the current device is, use the mobileCanSendMail function. This returns true if the mail client is configured.

Note: Once the mobileComposeMail command is called, you have no more control over what the user does with the message. They are free to modify the message and the addresses as they see fit.

Tagsnetworking