The AppStudio AppFramework provides an InterAppCommunication plug-in, used for components that control interaction between your app and others. It's recommended that default apps be set up before using functionality to communicate with them. To use this functionality, you first need to include the following import statement:
Prior to AppStudio 3.1, integrating a prefilled email into your app was best done with the UrlInfo component, using the queryParameters property to pass a subject and body of an email through a mailto URL. The following code sample uses the UrlInfo component to create an email containing system details:
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Button {
text: "Generate Email"onClicked: {
var urlInfo = AppFramework.urlInfo("mailto:example@example.com"), //Instantiates UrlInfo with an email address deviceDetails = [ //Collects information about both the device and app"%1: %2 (%3)".arg("Device OS").arg(Qt.platform.os).arg(AppFramework.osVersion),
"%1: %2".arg("Device Locale").arg(Qt.locale().name),
"%1: %2".arg("App Version").arg(app.info.version),
"%1: %2".arg("AppStudio Version").arg(AppFramework.version),
];
urlInfo.queryParameters = { //Uses queryParameters property to populate email subject and body"subject": "%1 %2".arg("Feedback for").arg(app.info.title),
"body": "\n\n%1".arg(deviceDetails.join("\n"))
};
Qt.openUrlExternally(urlInfo.url); //Uses Qt framework to open constructed UrlInfo }
}
This approach is limited, as it does not allow addressing the email to more than one recipient or support attachments. AppStudio 3.1 introduced an EmailComposer component, specifically designed to open a prefilled draft email to the device's default email client.
The following code sample demonstrates using the EmailComposer component to create the same form email as the UrlInfo sample above, this time sent to multiple people using the cc and bcc properties.