无法在Java中读取已发送邮件的密件抄送字段 [英] Unable to read BCC field of sent mails in java

查看:146
本文介绍了无法在Java中读取已发送邮件的密件抄送字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从传入邮件中提取密件抄送地址时,我遇到了一个问题. 这是使用的示例代码.

I am facing one problem while extracting BCC address from incoming mail. Here is the sample code that is used.

 public EmailVO dumpEnvelope(Message m) throws Exception {
             EmailVO emailVO = new EmailVO();
        if ((addresses = m.getRecipients(Message.RecipientType.BCC)) != null) {
            emailVO.setBcc(this.getAddresses(addresses, "BCC"));
        }
}

我在BCC中得到的是空值. 调试时,我在标题字段中找到了密件抄送收件人的名字,但是我无法访问该标题. 是此代码问题,还是在发送邮件时有一些特定的设置,例如不包括密件抄送"字段?

I am getting null value in BCC. While debugging I found BCC recipient's name in header field but I am not able to access that header. Is this code issue or there is some specific setting while sending mail like not to include BCC fields?

推荐答案

您可以检查Message对象,其中包含有关邮件的所有详细信息. 由于密件抄送是邮件的一部分,但也将被隐藏,但是据我所知,您可以从邮件标题中检索信息.

You can check your Message object which contains all the details about the mails. As the BCC is the part of mail but also it will be hidden, but as per my knowledge you can retrieve the information from your mail headers.

Address[] addresses = m.getHeader("Your Header Name HERE");

这将为您提供有关邮件中特定标头标签的所有详细信息.

This will give you all the details regarding your particular header tag in mails.

例如

Address[] addresses = m.getHeader("Delivered-To"); 

此标签将为您提供有关邮件收件人的所有信息,其中还包括密件抄送.

This tag will give you all the information about the recipients of the mail, which will also include BCC.

您还可以添加邮件的自定义标头.

you can also add your custom headers for mail.

这篇关于无法在Java中读取已发送邮件的密件抄送字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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