Qml: sending email with Qt.openUrlExternally



  • Hello everybody,

    I'm new to Qml and I'm trying to write an app, which should send an email when clicking a mouse area. This is, what I have already written:

    @
    // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.1

    Rectangle {
    id: rectangle1
    width: 360
    height: 360
    MouseArea {
    id: sendButton
    width: parent.width/2
    height: parent.height/2
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.verticalCenter: parent.verticalCenter
    onClicked: {
    Qt.openUrlExternally("mailto: to@adress.com" +
    "?subject=This is a subject" +
    "&body=This is the message")
    }

        Text {
            id: textSendeMail
            text: qsTr("Sende Mail")
            font.family: "MS Shell Dlg 2"
            anchors.fill: parent
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            font.pixelSize: 16
        }
    }
    

    }
    @

    Now, when clicking this area, Outlook starts. I mean, this is clear, as the name says to open the url externally. But is there a way to send an email directly, without opening Outlook.

    I wrote such a function in C# already, maybe it would be easier to understand, what I mean, when I just show you the C#-Code:

    @
    MailMessage message = new MailMessage();
    message.Subject = "This is the subject";
    message.Body = "Here is the message";
    message.From = new MailAddress("noreply@myaddress.com");
    message.To = new MailAddress("destination@address.com");
    SmtpClient smtp = new SmtpClient(ip);
    smtp.Send(message);
    @



  • The QtQuick module itself doesn't provide any support for this. There are a number of plugins available, including a Messaging plugin (see http://doc.qt.nokia.com/qtmobility/qml-plugins.html for the list of plugins), though from a quick look it appears it only supports reading messages. If that is the case, you might need to write your own C++ plugin to handle this functionality.

    Regards,
    Michael


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.