是否可以将java mail(mailto)函数用于.docx或格式化的.doc文件?

是否可以将java mail(mailto)函数用于.docx或格式化的.doc文件?,java,docx,mailto,doc,formatted-text,Java,Docx,Mailto,Doc,Formatted Text,这就是iam目前所做的: private void openEmailButtonMouseClicked(MouseEvent e) { String mailto = getClientConfigValue("email", "mailto"); String ccto = getClientConfigValue("email", "ccto"); String subject = getClientConfigValue("email", "subject")

这就是iam目前所做的:

private void openEmailButtonMouseClicked(MouseEvent e) {

    String mailto = getClientConfigValue("email", "mailto");
    String ccto = getClientConfigValue("email", "ccto");
    String subject = getClientConfigValue("email", "subject");
    String body = getClientConfigValue("email", "body");
    String currClient = getCurrClient();
    String bodyPath = getSpecificClientConfigPath(currClient) + body;
    String text = "";

    try {
        BufferedReader br = new BufferedReader(new FileReader(bodyPath));
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            text = sb.toString();
            while (text.contains(" ")) {
                text = text.replace(" ", "%20");
            }
            text = text.replaceAll("(\r\n|\r|\n|\n\r)", "%0A");
        }
        finally {
            br.close();
        }
    }
    catch (Exception e1) {
        e1.printStackTrace();
    }

    try {
        Desktop.getDesktop().mail(new URI("mailto:" + mailto + "?subject=" + subject + "&cc=" + ccto + "&body=" + text));

    }
    catch (Exception e1) {
        e1.printStackTrace();
    }
}

它非常适合.txt和.doc,无需文本格式。但它仍然不是很令人满意,因为我不能发送格式化的文本到standart桌面电子邮件cleint,因为我被迫生成一个url。有人知道通过mailto或其他方式将格式化文本解析到电子邮件客户端的方法吗?

没有。这不是java的限制,而是mailto url格式检查的限制。例如,在web浏览器中也是如此


请参见

确定。有没有其他方法可以将预定义的格式化文本发送到standart电子邮件客户端?您可以生成一个msg文件并使客户端打开它。