Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从mimessage获取/CC/BCC地址?_Java_Jakarta Mail - Fatal编程技术网

Java 从mimessage获取/CC/BCC地址?

Java 从mimessage获取/CC/BCC地址?,java,jakarta-mail,Java,Jakarta Mail,我需要从JavaMailMimeMessage对象获取to/CC/BCC地址。似乎我能做到这一点的唯一方法是通过getRecepients,但是我无法区分To字段与CC和BCC字段中的谁。有办法做到这一点吗 获取收件人 公共地址[]getRecipients(Message.RecipientType类型) 抛出消息异常 Returns the recepients specified by the type. The mapping between the type and the corre

我需要从JavaMail
MimeMessage
对象获取to/CC/BCC地址。似乎我能做到这一点的唯一方法是通过
getRecepients
,但是我无法区分
To
字段与
CC
BCC
字段中的谁。有办法做到这一点吗

获取收件人

公共地址[]getRecipients(Message.RecipientType类型) 抛出消息异常

Returns the recepients specified by the type. The mapping between the type and the corresponding RFC 822 header is as follows:

                Message.RecipientType.TO                "To"
                Message.RecipientType.CC                "Cc"
                Message.RecipientType.BCC               "Bcc"
                MimeMessage.RecipientType.NEWSGROUPS    "Newsgroups"

没有具有类型为的输入参数的方法。用这个…

注意,在你收到的邮件中,你永远找不到密件抄送收件人,这就是“密件抄送”的全部意义。

我对你的问题有答案,这对我来说很有用

Message msg=folder.getMessages(1);
地址[]a=m.getRecipients(Message.RecipientType.TO)

我没有投反对票。。。当涉及到客户时,您是正确的,但是我们不知道OP希望在链的哪个位置检查消息。是的,我们不知道,但是人们有时会对此感到困惑,所以我认为值得指出。如果你同意这是值得指出的信息,也许其他人可以投票反对?