如何解码邮件附件的标头?

时间:2018-07-19 16:02:56

标签: java email

我目前正在尝试获取电子邮件附件的文件名 为此,我正在使用Java Mail。 我尝试使用getFileName()和getDisposition函数,但它始终返回一个空值,并且我确定要使用的bodyPart是附件 然后,我查看附件的标题,发现了以下内容:

atnCida9h9YZu22t4QIA96yanqeY1GdMko1ASnJrwFRuhpsZVhRQOD2h4Uk1L4B8GiAdARYgpiHy:atnCida9h9YZu22t4QIA96yanqeY1GdMko1ASnJrwFRuhpsZVhRQOD2h4Uk1L4B8GiAdARYgpiHy
ARHDUYlnEilefN9pY9mmQRJuKcJVRQFMlsOfGXWFZgrLK9bIjZWh0DJtQCRYO7CmJDSla5rj3f8y:ARHDUYlnEilefN9pY9mmQRJuKcJVRQFMlsOfGXWFZgrLK9bIjZWh0DJtQCRYO7CmJDSla5rj3f8y
Ovd3EvuBvGYWhIf0A2kfV0zJ5nhKoZMAfaGVjten/MCs9EvrSyB3WNjDhpbkgeKVrtekT5KSZBh8:Ovd3EvuBvGYWhIf0A2kfV0zJ5nhKoZMAfaGVjten/MCs9EvrSyB3WNjDhpbkgeKVrtekT5KSZBh8
XZ2T1H8rXMmQzM8J9QkPnH7ETZjFA+c8Br8Z9wZGJh6lEhD9EF300yimLxhJ6QJN5OjDm5lPMmID:XZ2T1H8rXMmQzM8J9QkPnH7ETZjFA+c8Br8Z9wZGJh6lEhD9EF300yimLxhJ6QJN5OjDm5lPMmID
d6qR9OFPIytMvlxn85GRm7eN9JwJRliNK74g4h5F+KbwKrL/3xrJayIWNL//W0T6lohkuogVU3hG:d6qR9OFPIytMvlxn85GRm7eN9JwJRliNK74g4h5F+KbwKrL/3xrJayIWNL//W0T6lohkuogVU3hG
LpnwrdB78K0xzcTHWmJ8SGj2yiEJ+/7HQzI8wPI3AAAA//8DAFBLAwQUAAYACAAAACEAfwE3GH0B:LpnwrdB78K0xzcTHWmJ8SGj2yiEJ+/7HQzI8wPI3AAAA//8DAFBLAwQUAAYACAAAACEAfwE3GH0B
A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AAAAACfEgIAd29yZC93ZWJTZXR0aW5ncy54bWxQSwEC
LQAUAAYACAAAACEAWtlzyH4BAADvAgAAEQAAAAAAAAAAAAAAAADzEwIAZG9jUHJvcHMvY29yZS54:LQAUAAYACAAAACEAWtlzyH4BAADvAgAAEQAAAAAAAAAAAAAAAADzEwIAZG9jUHJvcHMvY29yZS54
bWxQSwECLQAUAAYACAAAACEAe9FzPNALAABqcwAADwAAAAAAAAAAAAAAAACoFgIAd29yZC9zdHls:bWxQSwECLQAUAAYACAAAACEAe9FzPNALAABqcwAADwAAAAAAAAAAAAAAAACoFgIAd29yZC9zdHls
ZXMueG1sUEsBAi0AFAAGAAgAAAAhAFjUDzfwAQAAPwYAABIAAAAAAAAAAAAAAAAApSICAHdvcmQv:ZXMueG1sUEsBAi0AFAAGAAgAAAAhAFjUDzfwAQAAPwYAABIAAAAAAAAAAAAAAAAApSICAHdvcmQv
Zm9udFRhYmxlLnhtbFBLAQItABQABgAIAAAAIQB/ATcYfQEAANUCAAAQAAAAAAAAAAAAAAAAAMUk:Zm9udFRhYmxlLnhtbFBLAQItABQABgAIAAAAIQB/ATcYfQEAANUCAAAQAAAAAAAAAAAAAAAAAMUk
AgBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAAMAAwABAMAAHgnAgAAAA==:AgBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAAMAAwABAMAAHgnAgAAAA==

要查找附件,我正在使用此Java函数:

            if(MailContentType.contains("multipart/MIXED")){
                mult = (Multipart) getMail().getContent();
                System.out.println(mult.getCount());
                for(int i = 1; i < mult.getCount(); i++){
                    bodyP = (BodyPart) mult.getBodyPart(i);
                    headers = bodyP.getAllHeaders();
                    while (headers.hasMoreElements()) {
                        Header h = (Header) headers.nextElement();
                        //System.out.println(h.getName() + ":" + h.getValue());
                        //System.out.println("");                
                        String mID = h.getName();                
                        System.out.println((h.getName()) + ":" + (h.getValue()));
                    }

是否可以解码此附件的标头?

0 个答案:

没有答案