Sending mail with line breaks using QDesktopServices::openUrl

被刻印的时光 ゝ 提交于 2019-12-13 06:25:28

问题


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.


回答1:


Turned out it is an KMail bug: https://bugs.kde.org/show_bug.cgi?id=366981



来源:https://stackoverflow.com/questions/38946188/sending-mail-with-line-breaks-using-qdesktopservicesopenurl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!