我尝试使用 POI hsmf 从 Outlook .msg 文件中提取字段 BillingInformation,但每次都会收到 ChunkNotFoundException。我已在 Outlook 中验证该字段中有内容。
public class MessageReader {
private static final int SUBJECT_CHUNK = 0x0037;
private static final int BILLING_INFORMATION_CHUNK = 0x00008535;
public static void main(String[] argv) {
try {
MAPIMessage mapiMessage = new MAPIMessage("MessageWithBillingInformation.msg");
System.out.println(mapiMessage.getStringFromChunk(new StringChunk(SUBJECT_CHUNK, true)));
System.out.println(mapiMessage.getStringFromChunk(new StringChunk(BILLING_INFORMATION_CHUNK, true)));
} catch (IOException e) {
e.printStackTrace();
} catch (ChunkNotFoundException e) {
e.printStackTrace();
}
}
}
我找到的所有文档都将 0x00008535 列为帐单信息的正确 ID: http://msdn.microsoft.com/en-us/library/cc765867.aspx
谢谢
最佳答案
使用 chunkID 0x800A 可以读取账单信息字段,因此代码如下所示:
public class MessageReader {
private static final int SUBJECT_CHUNK = 0x0037;
private static final int BILLING_INFORMATION_CHUNK = 0x800A;
public static void main(String[] argv) {
try {
MAPIMessage mapiMessage = new MAPIMessage("MessageWithBillingInformation.msg");
System.out.println(mapiMessage.getStringFromChunk(new StringChunk(SUBJECT_CHUNK, true)));
System.out.println(mapiMessage.getStringFromChunk(new StringChunk(BILLING_INFORMATION_CHUNK, true)));
} catch (IOException e) {
e.printStackTrace();
} catch (ChunkNotFoundException e) {
e.printStackTrace();
}
}
}
关于java - 如何使用 Apache POI HSMF 读取公共(public)属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9415981/