[Interest] Sending mail with line breaks using QDesktopServices::openUrl

Bernhard Lindner private at bernhard-lindner.de
Mon Aug 15 20:29:16 CEST 2016


Hi!

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 at 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 at test.com&subject=test&body=line1%0D%0Aline2">test</a>

Any idea how to solve the line break problem?

-- 
Best Regards
Bernhard Lindner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/2119ad8b/attachment.sig>


More information about the Interest mailing list