简体   繁体   English

Java mailto到MIME

[英]Java mailto to MIME

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. 寻找一个Java库以将mailto链接转换为MIME消息,或至少填写mailto链接中包含的部分。 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). 我发现的唯一解决方案(一个SO问题)涉及使用Desktop ,我可以肯定我的应用程序不能依赖Desktop (高度并发,在Web服务器上运行)。

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: 以下代码使用Android的Uri类工作,从Android库中提取代码并不复杂:

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());
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM