AnsweredAssumed Answered

How to load default email client with an attachment?

Question asked by paul.haakma on May 25, 2016
Latest reply on Jan 15, 2019 by paul.haakma

Hi all


Has anyone found a way yet to send an email with an attachment? I realise that it is a wider QML issue rather than an AppStudio issue, and that there are security issues relating to adding attachments using the javascript 'mailto' code, but it does seem a major hole in the Qt/QML platform.


Below is the basic code to fire up the default email client, but I can't find any workaround that allows adding an attachment.


Our use case involves wanting to take a screenshot and then fire up an email with the image already attached, 'To' and 'Subject' already filled in, etc and allow the user to email that away.


I've tried adding an attachment query parameter (gets ignored by mail client) and embedding the image as an image tag base64 encoded (html coding gets ignored by mail client and is inserted as raw text).


Any other ideas or workarounds?





    function sendEmail() {       

        var subject = "my subject line";

        var body = "some text here";

        var urlInfo = AppFramework.urlInfo("mailto:");

        urlInfo.queryParameters = {

            "subject": subject,

            "body": body