问题
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