邮件阅读问题?

时间:2011-08-30 07:50:22

标签: java email

我有com.sun.mail.pop3.POP3Message对象,在该内容中我有以下格式代码,

Delivery has failed to these recipients or distribution lists:

anandnarekar@gmail.coxm

尝试将此邮件传递到收件人的电子邮件地址时发生错误。 Microsoft Exchange不会尝试为您重新发送此邮件。请尝试重新发送此消息,或向系统管理员提供以下诊断文本。

Diagnostic information for administrators:

Generating server: delivery

anandnarekar@gmail.coxm
#< #5.0.0 smtp; 554 5.4.4 [internal] Domain Lookup Failed> #SMTP#

Original message headers:

X-AuditID: ac1ec426-b7b3aae0000036b3-7c-4e3009fd2d34
Received: from SVHJ0032 ( [172.30.1.11])    by svhj0367.ideaconnect.com (Symantec
 Brightmail Gateway) with SMTP id BA.D0.14003.DF9003E4; Wed, 27 Jul 2011
 18:22:13 +0530 (IST)
Message-ID: <1502435725.1311770110726.JavaMail.wasadmin@SVHJ0032>
Date: Wed, 27 Jul 2011 18:05:10 +0530
From: <ebill.mh@idea.adityabirla.com>
To: <anandnarekar@gmail.coxm>
Subject: Your Idea Bill
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="----=_Part_67575_1171670486.1311770110725"
Thread-Topic: rsweb_7202772011060510
X-Brightmail-Tracker: AAAAAQAAAZE= </pre>
> Blockquote

如何检索Thread-Topic的值?

1 个答案:

答案 0 :(得分:0)

循环返回给您的文本并查找“Thread-Topic”。 找到后,您可以使用indexOf和substring函数来解析您的主题。 示例代码如下所示:

E:\jdk1.6.0_23\bin>type Test.java
public class Test
{
  public static void main(String[] args) {
    String str = "Thread-Topic: rsweb_7202772011060510";
    if (str.indexOf("Thread-Topic") != -1) {
      String topic = str.substring(str.indexOf(":") + 2);
      System.out.println(topic);
    }
  }
}
E:\jdk1.6.0_23\bin>javac Test.java

E:\jdk1.6.0_23\bin>java Test
rsweb_7202772011060510