How to load default email client with an attachment?

3755
3
Jump to solution
05-25-2016 02:45 AM
PaulHaakma
Regular Contributor

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?

Cheers,

-Paul

    function sendEmail() {       

        var subject = "my subject line";

        var body = "some text here";

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

        urlInfo.queryParameters = {

            "subject": subject,

            "body": body

        };

        Qt.openUrlExternally(urlInfo.url);

    }

0 Kudos
1 Solution

Accepted Solutions
PaulHaakma
Regular Contributor

By the way, if anyone stumbles across this old post, AppStudio now has a framework component called EmailComposer that can handle attachments and opens up the device's native email application to send it.

Nice work AppStudio team!

View solution in original post

0 Kudos
3 Replies
LucasDanzinger
Esri Frequent Contributor

Paul-

I opened up an enhancement to have native support for email in Qt, but it hasn't gotten a lot of traction. Maybe you can comment on it and add info about attachments?

https://bugreports.qt.io/browse/QTBUG-44803

Thanks,

Luke

0 Kudos
PaulHaakma
Regular Contributor

Thanks Luke - I have done that now, at least it's something.

0 Kudos
PaulHaakma
Regular Contributor

By the way, if anyone stumbles across this old post, AppStudio now has a framework component called EmailComposer that can handle attachments and opens up the device's native email application to send it.

Nice work AppStudio team!

0 Kudos