Java mailto to MIME

风格不统一 提交于 2019-12-02 12:13:11

问题


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).


回答1:


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


来源:https://stackoverflow.com/questions/12694972/java-mailto-to-mime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!