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

Henry Skoglund fromqt at tungware.se
Mon Aug 15 20:43:53 CEST 2016


On 2016-08-15 20:29, Bernhard Lindner wrote:
> 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?

Hi, I just did a quick test on my Linux with Thunderbird and Qt 5.7,
constructed a vanilla Widgets app, pasted in your line 
"QDesktopServices::..".
When I run it, "line1" and "line2" appears on separate lines, ok. 
Perhaps try upgrading to 5.7?

Rgrds Henry




More information about the Interest mailing list