I have written a method that recursively adds the content of the multiple BodyPart
's of a Multipart
message to a string. I don't know why but the first phrase in the string is null
- why?
Code:
protected void dumpPart(Part p, Email email) throws MessagingException, IOException
{
if (p.isMimeType("text/plain"))
{
if (!p.getContent().toString().equals(null))
email.setBody((String)p.getContent());
}
else if (p.isMimeType("multipart/*"))
{
Multipart mp = (Multipart)p.getContent();
for (int x = 0; x < mp.getCount(); x++)
{
dumpPart(mp.getBodyPart(x), email);
}
}
}
Output:
nullWe did not answer protests to our Order 637 filing...
"p.getContent().toString().equals(null)" is always going to be false.
What does email.setBody do?