Java mailto到MIME [英] Java mailto to MIME

查看:126
本文介绍了Java mailto到MIME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一个Java库,将mailto链接转换为MIME消息,或者至少填写mailto链接中包含的部分内容。我找到的唯一解决方案(一个SO问题)涉及使用 Desktop ,我非常确定我的应用程序不能依赖(高度并发,在Web服务器上运行)。

Looking for a Java library to convert a mailto link to a MIME message, or at least fill in the parts of it that are contained within the mailto link. Only solution I've found (an SO question) involves use of Desktop which I'm pretty sure my application cannot depend on (highly concurrent, running on a web server).

推荐答案

据我所知,简单的东西不存在。以下代码使用Android中的 Uri 类,从Android库中删除并不复杂:

As far as I can tell something simple does not exist. The following code worked using the Uri class from Android, which was not complicated to excise from the Android libraries:

MailTo mailTo = MailTo.parse(unsubscribeUrl);

        Map<String, String> headers = mailTo.getHeaders();
        Set<Map.Entry<String, String>> values = headers.entrySet();

        for (Map.Entry<String, String> header : values) {
            message.addHeader(header.getKey(), header.getValue());
        }

这篇关于Java mailto到MIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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