使用QDesktopServices :: openUrl发送带有换行符的邮件 [英] Sending mail with line breaks using QDesktopServices::openUrl
问题描述
这是我打算使用的代码:
QDesktopServices :: openUrl(QUrl(mailto:?to = test@test.com& subject = Test& body = line1%0D%0Aline2,QUrl :: TolerantMode));
邮件窗口打开,主题和收件人都可以。不幸的是,身体的换行不行。我也尝试过< br> ;, \\\
,但这些都没有。我也尝试过其他方式构建一个
,\r\\\
QUrl
,但只会变得更糟。
似乎不是一个KMail问题是因为当将以下内容写入HTML文档时,在Firefox中打开它并点击浏览器中的链接,它完全正是我想要的(包括正文中的换行符):
< a href =mailto:?to = test@test.com& subject = test& body = line1%0D%0Aline2> test< / a>
如何解决换行符问题?
更新:
kmailmailto:?to = test@test.com& subject = test& body = line1%0D%0Aline2
工作似乎是与KMail有关的问题。人们告诉我上面的语法与雷鸟有关。
原来是一个KMail错误: https://bugs.kde.org/show_bug.cgi?id=366981
I tried to send an e-mail with a prepared subject, receiver and body using Qt. The mail shall open in the system default mail client. I am testing on Linux with KMail and Qt 5.5.
This is the code I intended to use:
QDesktopServices::openUrl(QUrl("mailto:?to=test@test.com&subject=Test&body=line1%0D%0Aline2", QUrl::TolerantMode));
The mail window opens, subject and receiver are ok. Unfortunately the line breaks in the body do not work. I also tried <br>, \n, \r\n
but none of these worked. I also tried other ways of constructing a QUrl
but it only get worse.
It seems not to be an KMail issue because when writing the following into a HTML document, opening it in firefox and clicking the link in the browser, it does exactly what I want (including line breaks in the body text):
<a href="mailto:?to=test@test.com&subject=test&body=line1%0D%0Aline2">test</a>
How can I fix the line break problem?
UPDATE:
kmail "mailto:?to=test@test.com&subject=test&body=line1%0D%0Aline2"
also doesn't work. Seems to be a KMail related problem. People told me the above syntax works with thunderbird.
Turned out it is an KMail bug: https://bugs.kde.org/show_bug.cgi?id=366981
这篇关于使用QDesktopServices :: openUrl发送带有换行符的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!