使用消息启动默认邮件客户端的最简单方法是什么

What's the easiest way to start default mail client with message

我正在寻找使用自定义邮件打开系统默认邮件客户端的最简单方法。

有没有办法让这个OS独立?

你可以使用 Desktop class,它有一个 mail(URI) 方法。

Launches the mail composing window of the user default mail client, filling the message fields specified by a mailto: URI.

这是一个例子:

        Desktop desktop = Desktop.getDesktop();
        String message = "mailto:someuser@somedomain.com?subject=mySubject&body=someBody";
        URI uri = URI.create(message);
        try {
            desktop.mail(uri);
        } catch (IOException e) {
            e.printStackTrace();
        }