Open default mail app from within Qt with some html

后端 未结 2 1877
栀梦
栀梦 2020-12-20 08:05

How can I open the default compose mail window from the user\'s mail app from within a Qt app?

I found there is some class for mobile with Qtmobility, but I don\'t h

相关标签:
2条回答
  • 2020-12-20 08:43

    Old topic but :

    You could also try another way, as I did, using a web service. I have a php web service that send email to a specific mail address, so I just send the message data to this web service, that will handle the rest for me.

    This is to abstract yourself of using a desktop software that most of the time users don't have ( we all use gmail anyway, so you know ... ). In php :

    // sending mail to  my@address.com  
        $headers ='From: sender@address.com'."\n";
        $headers .="Reply-To: replyto@address.com"."\n";
        $headers .='Content-Type: text/plain; charset="iso-8859-1"'."\n";
        $headers .='Content-Transfer-Encoding: 8bit';
        mail('my@address.com', '[TAG] mail subject', "some body text.", $headers); 
    

    Careful of security though !

    0 讨论(0)
  • 2020-12-20 08:51

    There is no built in way in Qt to send email with HTML formatting. The Mailto method will work for unformatted text, e.g.

    QDesktopServices::openUrl(QUrl("mailto:?to=recipient@example.com&subject=The subject of an email&body=Here is some email body text", QUrl::TolerantMode));
    

    But this cannot be used for html formatted text.

    If you absolutely need HTML you will need to look at the options for your platform(s):

    • MAPI for Windows
    • AppleScript and Mail.app on OSX
    • Mail on Linux
    0 讨论(0)
提交回复
热议问题