ArcGIS for Developers

EmailComposer QML Type

(BETA) Compose a pre-filled draft email for a system's email client. More...

Import Statement: import ArcGIS.AppFramework.InterAppCommunication 1.0

Properties

Methods

Detailed Description

The EmailComposer component allows you to launch a system email client with a pre-filled draft email, ready to send, modify, delete or save as a draft. In order to take advantage of this plugin, it's recommended that the system have a default mail client set up before use.

All mail clients are supported on Android. On macOS and iOS, this component only supports the Mail app provided by the OS. On Windows, this component only supports Outlook. On Linux, only Thunderbird is supported.

The following code sample demonstrates usage of EmailComposer. A basic email with pre-filled text can be opened in your default email client with the press of a button. If this fails, an error message will display.

Be aware that, as of 4.3, the onComposeError signal has been removed and replaced with the error property and onErrorChanged signal. Your app will not launch unless the onComposeError signal is replaced.

Item {
        EmailComposer {
                id: emailcomposer
                to: "max@abc.com"
                cc: ["dan@abc.com", "matt@abc.com"]
                bcc: "betty@abc.com"
                subject: "email subject"
                body: "AppStudio is awesome!"
                html: true
                onErrorChanged: {
                        console.error("EmailComposer error:", JSON.stringify(error));
                }
        }

        Button {
                id: openEmailButton
                text: qsTr("Show Email")
                onClicked: {
                        emailcomposer.show()
                }
        }

        Text {
                id: error
                anchors.top: openEmailButton.bottom
        }
}

Property Documentation

attachments : var

The absolute path to the pre-filled email attachments. More than one attachment can be set by providing a comma separated list.

You can use the following code to convert a file URL to an absolute path.

emailComposer.attachments = AppFramework.urlInfo(fileUrl).localFile;

On Windows, providing an attachment will disable the use of HTML in the email body.

Multiple attachments can be included by referring to a list.

App {
    id: app
    width: 400
    height: 640

    property var attachmentList : []

    Button {
        id: selectFile
        text: "Select files and send email"

        onClicked: {
            docDialog.open()
        }
    }


    DocumentDialog {
        id: docDialog

        selectExisting: true
        selectMultiple: true
        selectFolder: false

        onAccepted: {
            attachmentList.push(fileUrls);
            console.log(attachmentList);
            emailComposer.attachments = attachmentList
            emailComposer.show()
        }
    }

    EmailComposer {
        id: emailComposer

        to: "example@email.com"
        subject: "Multiple Emails"
        body: "Please find the files in the attachments"

    }
}

bcc : var

The pre-filled address or addresses to blind carbon copy (BCC) the email to. More than one address can be set by providing a comma separated list.

If you provide an empty string, the email will fail to open on Windows. This property is also not currently supported on macOS; instead, the email address ro addresses will be added to the TO field.


body : string

The pre-filled body of the email. This can include HTML tags on all platforms; however, if an attachment is provided on Windows, HTML tags will not be supported.

This property is required on some Linux machines.


cc : var

The pre-filled address or addresses to carbon copy (CC) the email to. More than one address can be set by providing a comma separated list.

If you provide an empty string, the email will fail to open on Windows.


[read-only] error : EmailComposerError


html : bool

True if the body of the email contains HTML code. If false, the email will not parse HTML code and will display as plaintext.

This property becomes false if an attachment property is defined on Windows.


subject : string

The pre-filled subject line of the email.


to : var

The address or addresses to send the email to. More than one address can be set by providing a comma separated list.


Method Documentation

show()

Launch your default email client with a draft email.