使用一些html从Qt中打开默认邮件应用 [英] Open default mail app from within Qt with some html
问题描述
如何从Qt应用程序内的用户邮件应用程序中打开默认的撰写邮件窗口?
How can I open the default compose mail window from the user's mail app from within a Qt app?
我发现有一些使用Qtmobility的手机类,但是我正在使用台式机应用程序,因此我无权访问此类。
I found there is some class for mobile with Qtmobility, but I don't have access to this class as I'm working on a desktop app.
我还发现人们在其中使用带mailto的URL sheme。这对我不起作用,因为html在某个时候被剥离了,可能是因为url太长,并且html不是用html而是纯文本呈现的。
I also found people to use a URL sheme with a mailto in it. This isn't working for me because the html is stripped at some point, probably because of the url being too long and the html is not rendered in html but in plain text.
如何在Qt中预先编写邮件并打开默认的邮件应用程序?
How can I precompose a mail in Qt and open the default mail app?
推荐答案
Qt中没有内置方法发送HTML格式的电子邮件。 Mailto方法将适用于无格式的文本,例如
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));
但这不能用于用于html格式的文本。
But this cannot be used for html formatted text.
如果您绝对需要HTML,则需要查看平台的选项(s):
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
这篇关于使用一些html从Qt中打开默认邮件应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!