使用QDesktopServices :: openUrl发送带有换行符的邮件 [英] Sending mail with line breaks using QDesktopServices::openUrl

查看:537
本文介绍了使用QDesktopServices :: openUrl发送带有换行符的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用准备好的主题,接收者和身体使用Qt发送电子邮件。邮件将在系统默认邮件客户端中打开。我正在使用KMail和Qt 5.5在Linux上测试。



这是我打算使用的代码:

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆