Reputation: 12484
I'm trying to extract the "Subject" field from an email, but am having some trouble . I was able to get the "To" and "From" fields already, like so :
String messageTo = tikaMetadata.MESSAGE_TO; //Works fine
String toField = tikaMetadata.get(messageTo); //Works fine
System.out.println("From field is : " + fromField); //Works fine
System.out.println("To field is : " + toField); //Works fine
String messageSubj = tikaMetadata.getValues("Message:Raw-Header:Subject");
String subjField = tikaMetadata.get(messageTo); //Doesn't Work
How would we extract the subject field by using Tika ? any tips helpful thanks
Upvotes: 0
Views: 233
Reputation: 1334
You can try two ways:
String subjectObs = tikaMetadata.get(tikaMetadata.SUBJECT);
but where.SUBJECT
is deprecated
String subject = tikaMetadata.get(TikaCoreProperties.DESCRIPTION);
probably the substitute that is closest to Metadata.SUBJECT
(for more details about TikaCoreProperties look at this: tika documentation)
Upvotes: 6